diff options
author | Dan McGee <dan@archlinux.org> | 2010-10-04 17:44:40 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2010-10-04 17:44:40 -0500 |
commit | 82eb9de99335c0032986fb3273f9951756205fb9 (patch) | |
tree | e3f5270af40d9b840f7798b9ac40476de368523e /main/models.py | |
parent | e847030d83796a5f8cccce2fb409dd4d672f71f3 (diff) |
Make user profile a OneToOneFieldrelease_2010-10-05
We had this set up as a unique ForeignKey before, which adds some
indirection due to the RelatedManager object being there. By making it a
OneToOneField, we can get the profile object directly, enforce uniqueness,
and also use it in select_related() calls to make our profiles page a bit
more efficient.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main/models.py')
-rw-r--r-- | main/models.py | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/main/models.py b/main/models.py index 79d99e8c..10a77379 100644 --- a/main/models.py +++ b/main/models.py @@ -27,8 +27,7 @@ class UserProfile(models.Model): roles = models.CharField(max_length=255, null=True, blank=True) favorite_distros = models.CharField(max_length=255, null=True, blank=True) picture = models.FileField(upload_to='devs', default='devs/silhouette.png') - user = models.ForeignKey( - User, related_name='userprofile_user', unique=True) + user = models.OneToOneField(User, related_name='userprofile') allowed_repos = models.ManyToManyField('Repo', blank=True) class Meta: db_table = 'user_profiles' |