1๐
guest = get_object_or_404(Guest, pk=pk)
# The 404 will catch any bad requests
orders = Order.objects.filter(guest = guest, is_paid=False)
context = {'form': form}
context['orders'] = orders
remember to add it to your context and you can access it in the template
๐คAdam Donaghy
0๐
you could get the Orders via the foreign key, by default (if not set via related_name):
guest.order_set.objects
Good luck!
๐คNhan Hoang
- How to manage static files from Django 1.8 to Django 1.10
- Why is my request.post object not mutable after calling .copy()?
- Django 1.10.5: relation 'myapp_mymodel' does not exist even after migrating
- Add django url template tags to pandas html table with jQuery
- Issue with Django URL Mapping/DetailView
0๐
I think you need to query Order
instance from given Guest
check this my help you:
orders = Order.objects.filter(guest=guest).all()
this will retrieve list of orders that you want
๐คShehab ElDin
- How to pass both ListView and DetailView as parameters in views.py/urls.py?
- Invalid literal for int() with base 10: 'Requires moderation'
- Not able to pass API urls to the REST API app
- Access variables in the Redirect in django
Source:stackexchange.com