Reputation: 795
I'm getting the following error when trying to run python manage.py syncdb
command
CommandError: One or more models did not validate:
sms.message: 'originator' has a relation with model <class 'sms.models.message.Originator'>
, which has either not been installed or is abstract.
models.py
class Originator(models.Model):
originator_name = models.CharField(max_length=11)
user = models.ForeignKey(User, related_name='originators')
class Message(models.Model):
content = models.TextField(help_text=_(u'The body of the message.'))
recipient_number = models.CharField(max_length=32)
sender = models.ForeignKey('auth.User', related_name='sent_sms_messages')
originator = models.ForeignKey(Originator,
related_name='Messages')
I don't see an issue tho! Can anyone else?
What I did notice is that when I remove the FK in Message to Originator the tables are created bar Originator which never gets created!
This is the model I'm adding to....
Maybe something else going on here?
Thanks
Upvotes: 0
Views: 1155
Reputation: 795
It installed when I added....
class Meta:
app_label = 'sms'
To the Originator class
Upvotes: 4
Reputation: 599610
Are you sure User
is the auth.User model there? It seems to be referring to the Originator model itself, which is strange.
You should probably do the same as you do in Message
, and just use the string auth.User
as the target of the Originator.user
FK.
Upvotes: 1