...

/

Solution: Create My Listings Page

Solution: Create My Listings Page

Learn how to add the URL and create the view and template of the My Listings page.

My Listings URL

To set up the URL for the My Listings page, add the following piece of code in the urls.py in the app’s directory.

Press + to interact
path('my_listings/', views.my_listings, name='my_listings')

My Listings view

Press + to interact
def my_listings(request):
my_listings = Listings.objects.order_by('-list_date')
context = {'my_listings': my_listings}
return render(request, 'listings/my_listings.html', context)

The entire my_listings view is just a copy of the all_listings view. This is the case because we haven’t created users yet, so at this point, all listings belong to one person. Once we have different users creating a ...