Thursday, 12 September 2013

Django 1.7 migrations for User Profile

Django 1.7 migrations for User Profile

I'm fairly new to Django and I'm using the latest version 1.7 from git in
a virtual environment with python3.3.
I'm making a simple blog web app as a learning project and I'm running
into a migration issue using Django's new in-built migration tools.
When trying to run ./manage.py migrate blog I'm getting the following
error (trimmed):
"...first_blog/django-trunk/django/db/migrations/graph.py", line 40, in
add_dependency
raise KeyError("Dependency references nonexistent parent node %r" %
(parent,))
KeyError: "Dependency references nonexistent parent node ('auth',
'0001_initial')"
The model that is causing the error is this one, presumably because of the
relation to the User model
from django.contrib.auth.models import User
...
class Author(models.Model):
user = models.OneToOneField(User, related_name='profile')
def gravatar_url(self):
return "http://www.gravatar.com/avatar/%s?s=50" %
hashlib.md5(self.user.email).hexdigest()
User.profile = property(lambda u: Author.objects.get_or_create(user=u)[0])
I realise that this is still in development but I couldn't work out if it
was an issue with my code (more likely) or an issue with the new built-in
migration tools.
Database is SQLite and let me know if there is any other parts of my
(limited) code you need to see. This is also my first post on SO, so
hopefully I've formatted it all ok.
Thanks in advance for any help. (Just set up the project in github so you
can see the entire picture if desired:
https://github.com/simonwillcock/django-learning-blog)

1 comment: