Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #urls.py
- url(r'^$', HomeProfile.as_view(), name = 'profile_home'),
- url(r'^(?P<username>.+)/$', HomeProfile.as_view(), name = 'profile_home'),
- #views.py
- from django.contrib.auth import authenticate, login, logout
- from django.shortcuts import render, render_to_response, get_object_or_404, redirect
- from django.contrib.auth.decorators import login_required
- from django.contrib.auth.models import User
- from django.views.generic import ListView
- from django.http import Http404
- # Modules
- from userprofile.models import Profile
- class HomeProfile(ListView):
- context_object_name = "profile"
- template_name = "profile/presentation.html",
- def get_queryset(self):
- try:
- username = get_object_or_404(Profile, user=self.request.user)
- return username
- except Profile.DoesNotExist:
- raise Http404
- #models.py
- class Profile(models.Model):
- user = models.ForeignKey(User)
- ...
- #erreurs:
- No Profile matches the given query.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement