1๐
โ
Your practicalArea class should subclass models.Model as well. Try it like this:
class PracticalArea(models.Model):
practical_area = models.CharField(max_length=25)
class Meta:
db_table = 'practical_area'
def __unicode__(self):
return self.practical_area
class Profile(models.Model):
auth_user_id = models.ForeignKey(User, related_name='userProfile')
address = models.TextField(blank=True)
state = models.CharField(max_length=20)
practical_area = models.ForeignKey('PracticalArea', related_name='practical_Area')
company = models.CharField(max_length=40)
photo = models.CharField(max_length=250)
created_date = models.DateTimeField()
modify_date = models.DateTimeField()
class Meta:
db_table = 'adminPanal_profile'
def save(self):
if self.created_date == None:
self.created_date = datetime.now()
self.modify_date = datetime.now()
super(Profile, self).save()
๐คgwaramadze
0๐
You should give Model Name directly instead of giving it in string because django expect compete path to model class if you give model name in string.
practical_area = models.ForeignKey(practicalArea, related_name='practical_Area')
As you are doing it for User.
๐คCrazyGeek
Source:stackexchange.com