Friday, March 28, 2014

Re: User Profiles "user.get_profile()" returns 'matching query does not exist.'



it worked
thank you!!

On Saturday, September 20, 2008 9:14:42 PM UTC-4, Paddy Joy wrote:
The error message is telling you that the user has no profile
(Specifically there is no record in the table schedule.profile related
to the user).

Your app needs to take care of creating the user profile, even if it
going to be empty. What I have done in my case is I force the user to
create a profile when they first log on by checking if the profile

        # Check if logged in user has profile, if not redirect to
create profile
                profile = request.user.get_profile()
                return HttpResponseRedirect("/createprofile/")


On Sep 21, 8:48 am, mclovin <> wrote:
> I have spent about 2 hours on this so far, but havent been able to get
> it right, my model is:
> (located in schedule/, stripped down to just the profile)
> from django.contrib.auth.models import User
> class profile(models.Model):
>     user = models.ForeignKey(User, unique=True)
>     aim = models.CharField(max_length=100, blank=True)
>     website = models.CharField(max_length=100, blank=True)
> and i have this as my setting:
> AUTH_PROFILE_MODULE = 'schedule.profile'
> I did a syncdb and it showed the profile successfully being added...
> then i did in "python shell":
> from django.contrib.auth.models import User
> u = User.objects.get(pk=1)
> print u.get_profile().aim
> but I get this error:
> Traceback (most recent call last):
>   File "<console>", line 1, in <module>
>   File "/usr/lib/python2.5/site-packages/django/contrib/auth/
>", line 293, in get_profile
>     self._profile_cache =
> model._default_manager.get(
>   File "/usr/lib/python2.5/site-packages/django/db/models/",
> line 93, in get
>     return self.get_query_set().get(*args, **kwargs)
>   File "/usr/lib/python2.5/site-packages/django/db/models/",
> line 303, in get
>     % self.model._meta.object_name)
> DoesNotExist: profile matching query does not exist.
> anyone have any idea what is wrong?

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
To post to this group, send email to
Visit this group at
To view this discussion on the web visit
For more options, visit

No comments:

Post a Comment