please i try my best but i can display my models in a templates i have just created.
*Please have a look at the codes in the models.py file* from django.db import models from django.contrib.auth.models import User # Create your models here. class Link(models.Model): url=models.URLField(unique=True) def __str__(self): return self.url class Bookmark(models.Model): title=models.CharField(max_length=200) user=models.ForeignKey(User) link=models.ForeignKey(Link) def __str__(self): return self.title *Please have a look at the codes in the templates file call user_page.html* head> <meta charset="UTF-8"> <title>Django Bookmarks - User:{{ username }}</title> </head> <body> <h1>Bookmarks for {{ username }}</h1> {% if bookmarks %} <ul> {% for bookmark in bookmaks %} <li>{{ bookmarks.title}}</li> {% endfor %} </ul> {% else %} <p>No bookmark found.</p> {% endif %} </body> This the codes from the views.py file (the object of the user_page) from django.shortcuts import render from django.http import HttpResponse,Http404 from django.template import Context from django.template.loader import get_template from django.contrib.auth.models import User from . models import Bookmark,Link def user_page(request, username): try: user=User.objects.get(username=username) except: raise Http404('Requested user not found.') bookmarks=user.bookmark_set.all() template=get_template('user_page.html') variables=Context({ 'username':username, 'bookmarks': bookmarks }) output=template.render(variables) return HttpResponse(output) *i try it out but it only give me this* <https://lh3.googleusercontent.com/-OB60iPiyBoU/V9ertDA2BgI/AAAAAAAAAEo/Sr5kuhswLbcXgfHoWWz6GHyAivtbVZO6ACLcB/s1600/gg.png> -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/13bc97fb-359d-4be7-b1b9-9cdb84a4a3a9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.