Wednesday, July 30, 2014

Re: Unable to create migration with Error - One or more models did not validate:

Hi,

you've added a relation to the AssetPollingConfig model which is not defined.

Cheers

Am Mittwoch, 30. Juli 2014 13:34:52 UTC+2 schrieb Subodh Nijsure:
Hello,

I have following model definition and when I try to create a migration
using command,  'python manage.py schemamigration asset_mgmt
--initial' I am getting following error:

CommandError: One or more models did not validate:
asset_mgmt.alarmtable: 'polling_config' has a relation with model
AssetPollingConfig, which has either not been installed or is
abstract.

I have other classes that extend the TimeStampedModel and I don't see
this error, can someone point me towards reason I am getting this
error?


class TimeStampedModel(models.Model):
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)
    class Meta:
        abstract = True

class AssetPollingInfo(TimeStampedModel):
    id = models.AutoField(primary_key=True)
    alarm_text = models.CharField(max_length=800,blank=True,null=True)
    asset_id = models.ForeignKey('AssetInfo')
    thresholds = models.ForeignKey('ThresholdInfo')
    dispatch = models.ForeignKey('AlarmDispatchInfo')
    class Meta:
        ordering = ['-id']
    def __unicode__(self):
        return str(self.id)

class AlarmTable(TimeStampedModel):
    id = models.AutoField(primary_key=True)
    polling_config = models.ForeignKey('AssetPollingConfig')
    alarm_text = models.CharField(max_length=800,blank=False,null=False)
    event_type = models.SmallIntegerField(blank=False,null=False)
    trigger_point = models.IntegerField(blank=True,null=True)
    class Meta:
        ordering = ['-id']
    def __unicode__(self):
        return str(self.id)


-Subodh

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5a541fa1-208f-40ce-92f7-89546872d8d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment