Display purchase history from Django Admin





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















enter image description hereI am trying to show the purchase history per user on the each users dashboard. I have made some dummy orders in Stripe which are working but I am having difficulty displaying the orders in the order history section of the page.



I am also not sure the order is linking correctly to the registered user in the first place as I seem to be confusing myself with this method



Can somebody help me or point me in the right direction please?






<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">

<table class="table table-striped">
<h3>Your order history</h3>
<hr>

<tr>
<th>Date</th>
<th>Invoice ID</th>
<th>Description</th>
<th>Total</th>
</tr>
{% for orders in orders %}
<tr>
<td scope="row">{{ order.quantity }}</td>
<td>xxx</td>
<td>xxx</td>
<td>xxx</td>
</tr>
{% endfor %}

</table>

</div>





My checkout views.py






from django.contrib import messages, auth
from django.contrib.auth.decorators import login_required
from checkout.forms import MakePaymentForm
from django.shortcuts import render, get_object_or_404, redirect, reverse
from django.template.context_processors import csrf
from django.conf import settings
from babysitters.models import Babysitter
import stripe

# stripe.api_key = settings.STRIPE_SECRET


@login_required(login_url="/accounts/login")
def buy_now(request, id):
if request.method == 'POST':
form = MakePaymentForm(request.POST)
if form.is_valid():
try:
babysitter = get_object_or_404(Babysitter, pk=id)
customer = stripe.Charge.create(
amount= int(babysitter.price * 100),
currency="EUR",
description=babysitter.firstName,
card=form.cleaned_data['stripe_id'],
)
except (stripe.error.CardError):
messages.error(request, "Your card was declined!")

if customer.paid:
messages.success(request, "You have successfully paid")
return redirect(reverse('babysitters'))
else:
messages.error(request, "Unable to take payment")
else:
messages.error(request, "We were unable to take a payment with that card!")

else:
form = MakePaymentForm()
babysitter = get_object_or_404(Babysitter, pk=id)

args = {'form': form, 'publishable': settings.STRIPE_PUBLISHABLE, 'babysitter': babysitter}
args.update(csrf(request))

return render(request, 'checkout.html', args)





My Models.py file






from django.db import models
from babysitters.models import Babysitter
from django.contrib.auth.models import User

# Create your models here.

class Order(models.Model):
first_name = models.CharField(max_length=255, blank=True)
last_name = models.CharField(max_length=255, blank=True)
address1 = models.CharField(max_length=255, blank=True)
address2 = models.CharField(max_length=255, blank=True)
city = models.CharField(max_length=20, null=True)
county = models.CharField(max_length=100, null=True)
postcode = models.CharField(max_length=7, null=True)
email = models.CharField(max_length=50, blank=True, null=True)
phone = models.CharField(max_length=10, blank=True)
date = models.DateField()

def __str__(self):
return "{0}-{1}-{2}".format(self.id, self.date, self.user)



class OrderLineItem(models.Model):
user = models.ForeignKey(User, null=False),
order = models.ForeignKey(Order, null=False, related_name='orders')
babysitter = models.ForeignKey(Babysitter, null=False)
quantity = models.IntegerField(blank=False)

def __str__(self):
return "{0} {1} @ {2}".format(self.quantity, self.babysitter.firstName, self.babysitter.price)












share|improve this question

























  • When you say "History" are you talking about the page that gets displayed after one clicks on the "History" button in the "Change" object page?

    – Red Cricket
    Nov 25 '18 at 2:26











  • I have added a picture to show more clearly what I am trying to achieve.

    – Pierce O'Neill
    Nov 25 '18 at 10:01











  • So your problem is not related to the Django admin portal then?

    – Red Cricket
    Nov 25 '18 at 14:56











  • No. sorry for the confusion.

    – Pierce O'Neill
    Nov 25 '18 at 15:43


















1















enter image description hereI am trying to show the purchase history per user on the each users dashboard. I have made some dummy orders in Stripe which are working but I am having difficulty displaying the orders in the order history section of the page.



I am also not sure the order is linking correctly to the registered user in the first place as I seem to be confusing myself with this method



Can somebody help me or point me in the right direction please?






<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">

<table class="table table-striped">
<h3>Your order history</h3>
<hr>

<tr>
<th>Date</th>
<th>Invoice ID</th>
<th>Description</th>
<th>Total</th>
</tr>
{% for orders in orders %}
<tr>
<td scope="row">{{ order.quantity }}</td>
<td>xxx</td>
<td>xxx</td>
<td>xxx</td>
</tr>
{% endfor %}

</table>

</div>





My checkout views.py






from django.contrib import messages, auth
from django.contrib.auth.decorators import login_required
from checkout.forms import MakePaymentForm
from django.shortcuts import render, get_object_or_404, redirect, reverse
from django.template.context_processors import csrf
from django.conf import settings
from babysitters.models import Babysitter
import stripe

# stripe.api_key = settings.STRIPE_SECRET


@login_required(login_url="/accounts/login")
def buy_now(request, id):
if request.method == 'POST':
form = MakePaymentForm(request.POST)
if form.is_valid():
try:
babysitter = get_object_or_404(Babysitter, pk=id)
customer = stripe.Charge.create(
amount= int(babysitter.price * 100),
currency="EUR",
description=babysitter.firstName,
card=form.cleaned_data['stripe_id'],
)
except (stripe.error.CardError):
messages.error(request, "Your card was declined!")

if customer.paid:
messages.success(request, "You have successfully paid")
return redirect(reverse('babysitters'))
else:
messages.error(request, "Unable to take payment")
else:
messages.error(request, "We were unable to take a payment with that card!")

else:
form = MakePaymentForm()
babysitter = get_object_or_404(Babysitter, pk=id)

args = {'form': form, 'publishable': settings.STRIPE_PUBLISHABLE, 'babysitter': babysitter}
args.update(csrf(request))

return render(request, 'checkout.html', args)





My Models.py file






from django.db import models
from babysitters.models import Babysitter
from django.contrib.auth.models import User

# Create your models here.

class Order(models.Model):
first_name = models.CharField(max_length=255, blank=True)
last_name = models.CharField(max_length=255, blank=True)
address1 = models.CharField(max_length=255, blank=True)
address2 = models.CharField(max_length=255, blank=True)
city = models.CharField(max_length=20, null=True)
county = models.CharField(max_length=100, null=True)
postcode = models.CharField(max_length=7, null=True)
email = models.CharField(max_length=50, blank=True, null=True)
phone = models.CharField(max_length=10, blank=True)
date = models.DateField()

def __str__(self):
return "{0}-{1}-{2}".format(self.id, self.date, self.user)



class OrderLineItem(models.Model):
user = models.ForeignKey(User, null=False),
order = models.ForeignKey(Order, null=False, related_name='orders')
babysitter = models.ForeignKey(Babysitter, null=False)
quantity = models.IntegerField(blank=False)

def __str__(self):
return "{0} {1} @ {2}".format(self.quantity, self.babysitter.firstName, self.babysitter.price)












share|improve this question

























  • When you say "History" are you talking about the page that gets displayed after one clicks on the "History" button in the "Change" object page?

    – Red Cricket
    Nov 25 '18 at 2:26











  • I have added a picture to show more clearly what I am trying to achieve.

    – Pierce O'Neill
    Nov 25 '18 at 10:01











  • So your problem is not related to the Django admin portal then?

    – Red Cricket
    Nov 25 '18 at 14:56











  • No. sorry for the confusion.

    – Pierce O'Neill
    Nov 25 '18 at 15:43














1












1








1








enter image description hereI am trying to show the purchase history per user on the each users dashboard. I have made some dummy orders in Stripe which are working but I am having difficulty displaying the orders in the order history section of the page.



I am also not sure the order is linking correctly to the registered user in the first place as I seem to be confusing myself with this method



Can somebody help me or point me in the right direction please?






<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">

<table class="table table-striped">
<h3>Your order history</h3>
<hr>

<tr>
<th>Date</th>
<th>Invoice ID</th>
<th>Description</th>
<th>Total</th>
</tr>
{% for orders in orders %}
<tr>
<td scope="row">{{ order.quantity }}</td>
<td>xxx</td>
<td>xxx</td>
<td>xxx</td>
</tr>
{% endfor %}

</table>

</div>





My checkout views.py






from django.contrib import messages, auth
from django.contrib.auth.decorators import login_required
from checkout.forms import MakePaymentForm
from django.shortcuts import render, get_object_or_404, redirect, reverse
from django.template.context_processors import csrf
from django.conf import settings
from babysitters.models import Babysitter
import stripe

# stripe.api_key = settings.STRIPE_SECRET


@login_required(login_url="/accounts/login")
def buy_now(request, id):
if request.method == 'POST':
form = MakePaymentForm(request.POST)
if form.is_valid():
try:
babysitter = get_object_or_404(Babysitter, pk=id)
customer = stripe.Charge.create(
amount= int(babysitter.price * 100),
currency="EUR",
description=babysitter.firstName,
card=form.cleaned_data['stripe_id'],
)
except (stripe.error.CardError):
messages.error(request, "Your card was declined!")

if customer.paid:
messages.success(request, "You have successfully paid")
return redirect(reverse('babysitters'))
else:
messages.error(request, "Unable to take payment")
else:
messages.error(request, "We were unable to take a payment with that card!")

else:
form = MakePaymentForm()
babysitter = get_object_or_404(Babysitter, pk=id)

args = {'form': form, 'publishable': settings.STRIPE_PUBLISHABLE, 'babysitter': babysitter}
args.update(csrf(request))

return render(request, 'checkout.html', args)





My Models.py file






from django.db import models
from babysitters.models import Babysitter
from django.contrib.auth.models import User

# Create your models here.

class Order(models.Model):
first_name = models.CharField(max_length=255, blank=True)
last_name = models.CharField(max_length=255, blank=True)
address1 = models.CharField(max_length=255, blank=True)
address2 = models.CharField(max_length=255, blank=True)
city = models.CharField(max_length=20, null=True)
county = models.CharField(max_length=100, null=True)
postcode = models.CharField(max_length=7, null=True)
email = models.CharField(max_length=50, blank=True, null=True)
phone = models.CharField(max_length=10, blank=True)
date = models.DateField()

def __str__(self):
return "{0}-{1}-{2}".format(self.id, self.date, self.user)



class OrderLineItem(models.Model):
user = models.ForeignKey(User, null=False),
order = models.ForeignKey(Order, null=False, related_name='orders')
babysitter = models.ForeignKey(Babysitter, null=False)
quantity = models.IntegerField(blank=False)

def __str__(self):
return "{0} {1} @ {2}".format(self.quantity, self.babysitter.firstName, self.babysitter.price)












share|improve this question
















enter image description hereI am trying to show the purchase history per user on the each users dashboard. I have made some dummy orders in Stripe which are working but I am having difficulty displaying the orders in the order history section of the page.



I am also not sure the order is linking correctly to the registered user in the first place as I seem to be confusing myself with this method



Can somebody help me or point me in the right direction please?






<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">

<table class="table table-striped">
<h3>Your order history</h3>
<hr>

<tr>
<th>Date</th>
<th>Invoice ID</th>
<th>Description</th>
<th>Total</th>
</tr>
{% for orders in orders %}
<tr>
<td scope="row">{{ order.quantity }}</td>
<td>xxx</td>
<td>xxx</td>
<td>xxx</td>
</tr>
{% endfor %}

</table>

</div>





My checkout views.py






from django.contrib import messages, auth
from django.contrib.auth.decorators import login_required
from checkout.forms import MakePaymentForm
from django.shortcuts import render, get_object_or_404, redirect, reverse
from django.template.context_processors import csrf
from django.conf import settings
from babysitters.models import Babysitter
import stripe

# stripe.api_key = settings.STRIPE_SECRET


@login_required(login_url="/accounts/login")
def buy_now(request, id):
if request.method == 'POST':
form = MakePaymentForm(request.POST)
if form.is_valid():
try:
babysitter = get_object_or_404(Babysitter, pk=id)
customer = stripe.Charge.create(
amount= int(babysitter.price * 100),
currency="EUR",
description=babysitter.firstName,
card=form.cleaned_data['stripe_id'],
)
except (stripe.error.CardError):
messages.error(request, "Your card was declined!")

if customer.paid:
messages.success(request, "You have successfully paid")
return redirect(reverse('babysitters'))
else:
messages.error(request, "Unable to take payment")
else:
messages.error(request, "We were unable to take a payment with that card!")

else:
form = MakePaymentForm()
babysitter = get_object_or_404(Babysitter, pk=id)

args = {'form': form, 'publishable': settings.STRIPE_PUBLISHABLE, 'babysitter': babysitter}
args.update(csrf(request))

return render(request, 'checkout.html', args)





My Models.py file






from django.db import models
from babysitters.models import Babysitter
from django.contrib.auth.models import User

# Create your models here.

class Order(models.Model):
first_name = models.CharField(max_length=255, blank=True)
last_name = models.CharField(max_length=255, blank=True)
address1 = models.CharField(max_length=255, blank=True)
address2 = models.CharField(max_length=255, blank=True)
city = models.CharField(max_length=20, null=True)
county = models.CharField(max_length=100, null=True)
postcode = models.CharField(max_length=7, null=True)
email = models.CharField(max_length=50, blank=True, null=True)
phone = models.CharField(max_length=10, blank=True)
date = models.DateField()

def __str__(self):
return "{0}-{1}-{2}".format(self.id, self.date, self.user)



class OrderLineItem(models.Model):
user = models.ForeignKey(User, null=False),
order = models.ForeignKey(Order, null=False, related_name='orders')
babysitter = models.ForeignKey(Babysitter, null=False)
quantity = models.IntegerField(blank=False)

def __str__(self):
return "{0} {1} @ {2}".format(self.quantity, self.babysitter.firstName, self.babysitter.price)








<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">

<table class="table table-striped">
<h3>Your order history</h3>
<hr>

<tr>
<th>Date</th>
<th>Invoice ID</th>
<th>Description</th>
<th>Total</th>
</tr>
{% for orders in orders %}
<tr>
<td scope="row">{{ order.quantity }}</td>
<td>xxx</td>
<td>xxx</td>
<td>xxx</td>
</tr>
{% endfor %}

</table>

</div>





<div class="container">
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">

<table class="table table-striped">
<h3>Your order history</h3>
<hr>

<tr>
<th>Date</th>
<th>Invoice ID</th>
<th>Description</th>
<th>Total</th>
</tr>
{% for orders in orders %}
<tr>
<td scope="row">{{ order.quantity }}</td>
<td>xxx</td>
<td>xxx</td>
<td>xxx</td>
</tr>
{% endfor %}

</table>

</div>





from django.contrib import messages, auth
from django.contrib.auth.decorators import login_required
from checkout.forms import MakePaymentForm
from django.shortcuts import render, get_object_or_404, redirect, reverse
from django.template.context_processors import csrf
from django.conf import settings
from babysitters.models import Babysitter
import stripe

# stripe.api_key = settings.STRIPE_SECRET


@login_required(login_url="/accounts/login")
def buy_now(request, id):
if request.method == 'POST':
form = MakePaymentForm(request.POST)
if form.is_valid():
try:
babysitter = get_object_or_404(Babysitter, pk=id)
customer = stripe.Charge.create(
amount= int(babysitter.price * 100),
currency="EUR",
description=babysitter.firstName,
card=form.cleaned_data['stripe_id'],
)
except (stripe.error.CardError):
messages.error(request, "Your card was declined!")

if customer.paid:
messages.success(request, "You have successfully paid")
return redirect(reverse('babysitters'))
else:
messages.error(request, "Unable to take payment")
else:
messages.error(request, "We were unable to take a payment with that card!")

else:
form = MakePaymentForm()
babysitter = get_object_or_404(Babysitter, pk=id)

args = {'form': form, 'publishable': settings.STRIPE_PUBLISHABLE, 'babysitter': babysitter}
args.update(csrf(request))

return render(request, 'checkout.html', args)





from django.contrib import messages, auth
from django.contrib.auth.decorators import login_required
from checkout.forms import MakePaymentForm
from django.shortcuts import render, get_object_or_404, redirect, reverse
from django.template.context_processors import csrf
from django.conf import settings
from babysitters.models import Babysitter
import stripe

# stripe.api_key = settings.STRIPE_SECRET


@login_required(login_url="/accounts/login")
def buy_now(request, id):
if request.method == 'POST':
form = MakePaymentForm(request.POST)
if form.is_valid():
try:
babysitter = get_object_or_404(Babysitter, pk=id)
customer = stripe.Charge.create(
amount= int(babysitter.price * 100),
currency="EUR",
description=babysitter.firstName,
card=form.cleaned_data['stripe_id'],
)
except (stripe.error.CardError):
messages.error(request, "Your card was declined!")

if customer.paid:
messages.success(request, "You have successfully paid")
return redirect(reverse('babysitters'))
else:
messages.error(request, "Unable to take payment")
else:
messages.error(request, "We were unable to take a payment with that card!")

else:
form = MakePaymentForm()
babysitter = get_object_or_404(Babysitter, pk=id)

args = {'form': form, 'publishable': settings.STRIPE_PUBLISHABLE, 'babysitter': babysitter}
args.update(csrf(request))

return render(request, 'checkout.html', args)





from django.db import models
from babysitters.models import Babysitter
from django.contrib.auth.models import User

# Create your models here.

class Order(models.Model):
first_name = models.CharField(max_length=255, blank=True)
last_name = models.CharField(max_length=255, blank=True)
address1 = models.CharField(max_length=255, blank=True)
address2 = models.CharField(max_length=255, blank=True)
city = models.CharField(max_length=20, null=True)
county = models.CharField(max_length=100, null=True)
postcode = models.CharField(max_length=7, null=True)
email = models.CharField(max_length=50, blank=True, null=True)
phone = models.CharField(max_length=10, blank=True)
date = models.DateField()

def __str__(self):
return "{0}-{1}-{2}".format(self.id, self.date, self.user)



class OrderLineItem(models.Model):
user = models.ForeignKey(User, null=False),
order = models.ForeignKey(Order, null=False, related_name='orders')
babysitter = models.ForeignKey(Babysitter, null=False)
quantity = models.IntegerField(blank=False)

def __str__(self):
return "{0} {1} @ {2}".format(self.quantity, self.babysitter.firstName, self.babysitter.price)





from django.db import models
from babysitters.models import Babysitter
from django.contrib.auth.models import User

# Create your models here.

class Order(models.Model):
first_name = models.CharField(max_length=255, blank=True)
last_name = models.CharField(max_length=255, blank=True)
address1 = models.CharField(max_length=255, blank=True)
address2 = models.CharField(max_length=255, blank=True)
city = models.CharField(max_length=20, null=True)
county = models.CharField(max_length=100, null=True)
postcode = models.CharField(max_length=7, null=True)
email = models.CharField(max_length=50, blank=True, null=True)
phone = models.CharField(max_length=10, blank=True)
date = models.DateField()

def __str__(self):
return "{0}-{1}-{2}".format(self.id, self.date, self.user)



class OrderLineItem(models.Model):
user = models.ForeignKey(User, null=False),
order = models.ForeignKey(Order, null=False, related_name='orders')
babysitter = models.ForeignKey(Babysitter, null=False)
quantity = models.IntegerField(blank=False)

def __str__(self):
return "{0} {1} @ {2}".format(self.quantity, self.babysitter.firstName, self.babysitter.price)






python django django-admin






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 25 '18 at 10:00







Pierce O'Neill

















asked Nov 25 '18 at 0:10









Pierce O'NeillPierce O'Neill

339514




339514













  • When you say "History" are you talking about the page that gets displayed after one clicks on the "History" button in the "Change" object page?

    – Red Cricket
    Nov 25 '18 at 2:26











  • I have added a picture to show more clearly what I am trying to achieve.

    – Pierce O'Neill
    Nov 25 '18 at 10:01











  • So your problem is not related to the Django admin portal then?

    – Red Cricket
    Nov 25 '18 at 14:56











  • No. sorry for the confusion.

    – Pierce O'Neill
    Nov 25 '18 at 15:43



















  • When you say "History" are you talking about the page that gets displayed after one clicks on the "History" button in the "Change" object page?

    – Red Cricket
    Nov 25 '18 at 2:26











  • I have added a picture to show more clearly what I am trying to achieve.

    – Pierce O'Neill
    Nov 25 '18 at 10:01











  • So your problem is not related to the Django admin portal then?

    – Red Cricket
    Nov 25 '18 at 14:56











  • No. sorry for the confusion.

    – Pierce O'Neill
    Nov 25 '18 at 15:43

















When you say "History" are you talking about the page that gets displayed after one clicks on the "History" button in the "Change" object page?

– Red Cricket
Nov 25 '18 at 2:26





When you say "History" are you talking about the page that gets displayed after one clicks on the "History" button in the "Change" object page?

– Red Cricket
Nov 25 '18 at 2:26













I have added a picture to show more clearly what I am trying to achieve.

– Pierce O'Neill
Nov 25 '18 at 10:01





I have added a picture to show more clearly what I am trying to achieve.

– Pierce O'Neill
Nov 25 '18 at 10:01













So your problem is not related to the Django admin portal then?

– Red Cricket
Nov 25 '18 at 14:56





So your problem is not related to the Django admin portal then?

– Red Cricket
Nov 25 '18 at 14:56













No. sorry for the confusion.

– Pierce O'Neill
Nov 25 '18 at 15:43





No. sorry for the confusion.

– Pierce O'Neill
Nov 25 '18 at 15:43












1 Answer
1






active

oldest

votes


















1














The order history isn't showing because you're using a loop variable named orders but you're referring to order when accessing each attribute. Rename the loop variable to order:



{% for order in orders %}
<tr>
<td scope="row">{{ order.quantity }}</td>
<td>xxx</td>
<td>xxx</td>
<td>xxx</td>
</tr>
{% endfor %}





share|improve this answer
























  • Thank you. I will give this a try.

    – Pierce O'Neill
    Nov 25 '18 at 20:57












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53463542%2fdisplay-purchase-history-from-django-admin%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














The order history isn't showing because you're using a loop variable named orders but you're referring to order when accessing each attribute. Rename the loop variable to order:



{% for order in orders %}
<tr>
<td scope="row">{{ order.quantity }}</td>
<td>xxx</td>
<td>xxx</td>
<td>xxx</td>
</tr>
{% endfor %}





share|improve this answer
























  • Thank you. I will give this a try.

    – Pierce O'Neill
    Nov 25 '18 at 20:57
















1














The order history isn't showing because you're using a loop variable named orders but you're referring to order when accessing each attribute. Rename the loop variable to order:



{% for order in orders %}
<tr>
<td scope="row">{{ order.quantity }}</td>
<td>xxx</td>
<td>xxx</td>
<td>xxx</td>
</tr>
{% endfor %}





share|improve this answer
























  • Thank you. I will give this a try.

    – Pierce O'Neill
    Nov 25 '18 at 20:57














1












1








1







The order history isn't showing because you're using a loop variable named orders but you're referring to order when accessing each attribute. Rename the loop variable to order:



{% for order in orders %}
<tr>
<td scope="row">{{ order.quantity }}</td>
<td>xxx</td>
<td>xxx</td>
<td>xxx</td>
</tr>
{% endfor %}





share|improve this answer













The order history isn't showing because you're using a loop variable named orders but you're referring to order when accessing each attribute. Rename the loop variable to order:



{% for order in orders %}
<tr>
<td scope="row">{{ order.quantity }}</td>
<td>xxx</td>
<td>xxx</td>
<td>xxx</td>
</tr>
{% endfor %}






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 25 '18 at 20:43









Will KeelingWill Keeling

12.6k22736




12.6k22736













  • Thank you. I will give this a try.

    – Pierce O'Neill
    Nov 25 '18 at 20:57



















  • Thank you. I will give this a try.

    – Pierce O'Neill
    Nov 25 '18 at 20:57

















Thank you. I will give this a try.

– Pierce O'Neill
Nov 25 '18 at 20:57





Thank you. I will give this a try.

– Pierce O'Neill
Nov 25 '18 at 20:57




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53463542%2fdisplay-purchase-history-from-django-admin%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()