A quick (maybe stupid) question. This is the flow of my site: the user logs in and is redirected to the userβs admin page. On this admin page, they have the opportunity to make a "Profile". I want to associate the profile that they create with the User data, so that 1 User is associated with 1 profile.
For some reason, the following doesn't work (just trying to tie
UserAdmin.Models
from django.db import models from django.contrib.auth.models import User class Profile(models.Model): username = models.ForeignKey(User) firstname = models.CharField(max_length=200) lastname = models.CharField(max_length=200) email = models.EmailField(max_length=200) def __unicode__(self): return self.username
UserAdmin.Views
def createprofile(request): user = User.objects.get(id=1) profile = Profile(username=user, firstname='Joe', lastname='Soe', email=' Joe@Soe.com ') profile.save()
I keep getting: the useradmin_profile table does not have a column named username_id
Any ideas? Appreciated.
EDIT:
I deleted my db and started a new syncdb, changed to username = models.OneToOneField (User). Now I get I can not assign "u'superuser": "Profile.username" must be an instance of "User".
user1059105
source share