I just got started with Django (I'm using v1.0).. and have been trying
(unsuccessfully) to add this line to my first model "author =
models.ForeignKey(User)"... (see my models.py below). Everytime I do
so and sync I get the following message:
^[[31;1mError: One or more models did not validate:
^[[31;1mauth.message: Accessor for field 'user' clashes with related
field 'User.message_set'. Add \
a related_name argument to the definition for 'user'.
^[[0m^[[31;1mmusables.message: Accessor for field 'author' clashes
with related field 'User.message\
_set'. Add a related_name argument to the definition for 'author'.
^[[0m
The odd thing is I decided to copy my model (see below it is called
MessageV2) and then it worked fine? Is there something "magical"
about the first model you define in a file? Is Django storing some
extra state somewhere.. btw.. i've been "DROP TABLE"ing all my tables
before manage.py syncdb ?
Steven
===== models.py ======
from django.db import models
from django.contrib.auth.models import User
# Create your models here.
class Message(models.Model):
sent_date = models.DateTimeField()
subject = models.CharField(max_length = 100)
body = models.TextField()
slug = models.SlugField(max_length = 100)
# author = models.ForeignKey(User) # uncommenting this causes the
problem
def __unicode__(self):
return self.subject
class MessageV2(models.Model):
sent_date = models.DateTimeField()
subject = models.CharField(max_length = 100)
body = models.TextField()
slug = models.SlugField(max_length = 100)
author = models.ForeignKey(User) # this is where things are
confusing
def __unicode__(self):
return self.subject
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---