I've got a chicken and egg problem here. Firstly I've got a userprofile class which builds upon the default user model of django.
class UserProfile(models.Model):
def __unicode__(self):
return self.user.username
user = models.OneToOneField(User, unique=True)
exam = models.ForeignKey('questions.Exam', null=True)
Next, I've got an Exam class
class Exam(models.Model):
def __unicode__(self):
return self.id
user = models.ForeignKey(UserProfile)
The UserProfile and Exam models are in different apps. However, they both have foreignkey to each other. I know its bad design, but its my peculiar requirement in my case. However UserProfile foreignkey to Exam can be Null. But whenever I try to create Exam in Admin, I get error saying "UserProfile" is a required field. And when I try to create User, the reverse happens. Is there a way to break this deadlock? Or should I redesign my app?