I have the following models with foreignkey relation.
class UserProfile(models.Model):
profile_id = models.CharField(
('Profile id'), max_length=30, default='', blank=True)
first_name = models.CharField(
('first name'), max_length=30, default='', blank=True)
last_name = models.CharField(
('last name'), default='', max_length=30, blank=True)
Profile Image model has a foreignkey relation to UserProfile model:
class UserProfileImage(models.Model):
userprofile = models.ForeignKey(UserProfile)
image = models.ImageField(upload_to='profile_pic/images',blank=True,null=True)
def __unicode__(self):
return self.userprofile.profile_id
I want to save both forms in one view and for edit also it should pass both form instances.How will I save both forms in one view?