I have this form:
class TourForm(ModelForm):
class Meta:
model = Tour
I wanna design a edit page,so i send tour_id to page and get tour with that tour_id,now I wanna fill this form with tour instance I've gotton.some thing like this in views.py:
tour=Tour.objects.get(pk=tour_id)
tform = TourForm(request.POST, request.FILES,instance=tour)
any help?
update:
these are models:
class Gallery(models.Model):
HeadImage = models.ImageField(upload_to="gallery")
class Image(models.Model):
Image = models.ImageField(upload_to="gallery")
Gallery = models.ForeignKey(Gallery, related_name='images')
class Tour(models.Model):
Name=models.CharField(max_length=100)
Count=models.SmallIntegerField()
PriceUnit=models.ForeignKey(PriceUnit)
Price=models.CharField(max_length=12)
Description=models.TextField()
ActionDate=models.DateTimeField(auto_now=True,editable=False)
ActionUser=models.ForeignKey(User,editable=False)
StatusType=models.ForeignKey(StatusType)
Gallery = models.OneToOneField(Gallery,editable=False)
fields that are foreigkey like PriceUnit and StatusType,doesn't fill in form.
thanks in advance