On Jan 22, 2008 3:00 AM, Carl Karsten <[EMAIL PROTECTED]> wrote:
> # core/models.py
> from django.db import models
> from django.contrib.auth.models import User
> import ridgemoor.msg.models
> from time import strftime
>
> class Message(models.Model):
> to = models.ForeignKey(User, related_name = "messages_received")
> sender = models.ForeignKey(User, related_name = "messages_sent")
> subject = models.CharField(max_length=50, blank=False)
> sent = models.DateTimeField(auto_now_add=True)
> recieved = models.DateTimeField(null=True)
> body = models.TextField()
> status = models.CharField(max_length=1, blank=True, null=True)
> def __str__(self):
> return self.subject
> class Admin:
> list_display = ('sent', 'to', 'sender', 'subject')
>
>
> [EMAIL PROTECTED]:~/ridgemoor$ PYTHONPATH=$HOME ./manage.py syncdb
> Error: One or more models did not validate:
> core.message: Accessor for field 'to' clashes with related field
> 'User.messages_received'. Add a related_name argument to the definition
> for 'to'.
>
> Something broke my app. it is most likely the changes I have been making
> to get
> things working under apache, but this may be a change to trunk.
>
> It is telling me to add something that is already there.
The error is telling you that by the time the "to" field of Message is
processed, User already has a "messages_received" relation. Yes, the
message is a bit misleading, since you already have a related_name field,
but what it really means is you need to specify a related_name that doesn't
already exist for User. What is in ridgemoor.msg.models? I'd guess there's
another model with a ForeignKey to User specifying a related_name of
"messages_received". Do you really need two models with this relation? If
so you'll need to specify different related_names for the two.
Karen
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---