Reputation: 2070
im creating 2 models in django, the first one has django auth user as a foreign key, the second has this first model as a foreign key like this in models.py :
class SGIUsers(models.Model):
charge = models.CharField('Cargo', max_length=80)
user = models.ForeignKey(User, unique=True)
class ResponsibleStateFlow(ModelBase):
user = models.ForeignKey(SGIUsers, verbose_name = 'Responsable', blank = False )
process= models.ForeignKey(Process, verbose_name='Proceso')
But i get this error :
sgiprocess.ResponsibleStateFlow.user: (fields.E300) Field defines a relation with model 'SGIUsers', which is either not installed, or is abstract.
I already imported django auth user of course. Any idea ??
Upvotes: 0
Views: 322
Reputation: 2070
Found it, i needed to define an app label with the app name in class meta for SGIUsers like this first:
class Meta:
app_label = 'app_name'
And then call the foreign with 'app_name.Modelname'
Upvotes: 1
Reputation: 108
try to add the app name:
field=models.ForeignKey('app_name.ModelName')
Upvotes: 1