Reputation: 4517
My code is as shown below:
holidayRequest.py
from django.db import models
from enum import Enum
class HolidayRequests(models.Model):
class Meta:
db_table = 'holidays_requests'
app_label = 'dashboard'
name = models.CharField(max_length = 255,null= False)
email = models.CharField(max_length = 255,null=False)
ph_no = models.CharField(max_length =255,null=False)
holiday = models.ForeignKey('holidays',on_delete=models.CASCADE)
holiday.py
from django.db import models
from enum import Enum
class Holiday (models.Model):
class Meta:
db_table = 'holidays'
app_label = 'dashboard'
holiday_price = models.CharField(max_length = 255,null =False)
holiday_title = models.CharField(max_length=255,null=False)
init.py (inside models folder)
from holidayRequest import HolidayRequests
from holiday import Holiday
the moment I run migrations, I get the following error:
dashboard.HolidayRequests.holiday: (fields.E300) Field defines a relation with model 'holidays', which is either not installed, or is abstract.
dashboard.HolidayRequests.holiday: (fields.E307) The field dashboard.HolidayRequests.holiday was declared with a lazy reference to 'dashboard.holidays', but app 'dashboard' doesn't provide model 'holidays'.
Upvotes: 0
Views: 482
Reputation: 487
You have to specify the model name, not the db_table_name
holiday = models.ForeignKey('Holiday',on_delete=models.CASCADE)
.
Also, remove imports from __init__.py
.
Upvotes: 3