On Sep 8, 1:34 pm, "Matthias Kestenholz" <[EMAIL PROTECTED]> wrote:
> Hi,
>
>
>
> On Mon, Sep 8, 2008 at 12:42 PM, sveri <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > i am using Django 1.0 and try to extent the usermodel, which works so
> > far
> > for adding new users.
>
> > But when i want to retrieve a user profile i get a weird error:
>
> > user = get_object_or_404(User, id=9)
> > user.get_profile()
>
> > Traceback (most recent call last):
> >  File "<console>", line 1, in <module>
> >  File "/usr/lib/python2.5/site-packages/django/contrib/auth/
> > models.py", line 293, in get_profile
> >    self._profile_cache =
> > model._default_manager.get(user__id__exact=self.id)
> > AttributeError: 'NoneType' object has no attribute '_default_manager'
>
> Have you imported the User model before trying get_object_or_404?
> (f.e. like that):
>
> from django.contrib.auth.models import User
>

Yes, i imported all needed libraries.
The User stuff works for adding new users with:

user = User.objects.create(username=un, first_name=fn,last_name=ln,
email=email,
                                       is_active=False)
user.set_password(pw)
user.save()

up = UserProfile.objects.create(user=user, city=city, plz=plz,
street=street, housenumber=hn)
up.save()

I checked the tables (mysql) and they all contain correct data.

The error occurs also when i try to get the userprofile
via console.


Greetings
Sven


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to