Hi, I tried this in the django shell after I changed the line to
user = models.OneToOneField(User, related_name='userprofile') but I get
this error.
>>> import userprofile.models
>>> from django.contrib.auth.models import User
>>> u = User.objects.get(username='test1')
>>> print u
test1
>>> u.userprofile
Traceback (most recent call last):
File "<input>", line 1, in <module>
File
"/home/voger/ssite_venv/lib/python2.7/site-packages/django/db/models/fields/related.py",
line 206, in __get__
self.related.get_accessor_name()))
DoesNotExist: User has no userprofile.
On 03/17/2014 07:33 PM, voger wrote:
> Hi, thanks for the reply. I didn't know about the related_name. I tried
> it, did a syncdb witch didn't do anything but still the extra fields
> don't save.
>
> On 03/17/2014 06:25 PM, Fabio Caritas Barrionuevo da Luz wrote:
>> Voyager, Have you tried putting related_name in the Foreign Key?
>>
>> class UserProfile(models.Model):
>> # This line is required. Links UserProfile to a User model
>> instance.
>> user = models.ForeignKey(User, unique=True,
>> *related_name='userprofile'*)
>>
>
--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/53279280.5020100%40yahoo.gr.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment