Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6728559
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:11:08+00:00 2026-05-26T10:11:08+00:00

I have this form: class TourForm(ModelForm): class Meta: model = Tour I wanna design

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:11:08+00:00Added an answer on May 26, 2026 at 10:11 am

    I think that you should not pass instance nad request.POSt at the same time. Try to do something like this:

    if request.method == "POST":
        tform = TourForm(request.POST, request.FILES)
    else
        tform = TourForm(instance=tour)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sample form: class AdminDiscountForm(ModelForm): class Meta: model = Discount exclude =
I Have this Form class MyModelForm(forms.ModelForm): boolfield = forms.TypedChoiceField(coerce=bool, choices=((False, 'No'), (True, 'Yes')), widget=forms.RadioSelect
Say I have this simple form: class ContactForm(forms.Form): first_name = forms.CharField(required=True) last_name = forms.CharField(required=True)
I have a form that looks like this: class SampleForm(forms.Form): text = forms.CharField(max_length=100) In
I have a Django my_forms.py like this: class CarSearchForm(forms.Form): # lots of fields like
I have this form. Basically what I want is to send a auto-response with
I have this form class : class MyForm(forms.Form): def __init__(self, *args, **kwargs): self.notvalidate =
I have this simple Post model: class Post(models.Model): title = models.CharField(_('title'), max_length=60, blank=True, null=True)
Let's say I have this form: class SimpleUploadForm(forms.Form): file = forms.FileField() I have this
..whatdoyoucallitanyway.. I have this model: class Kaart(models.Model): name = models.CharField(max_length=200, name=Kaardi peakiri, help_text=Sisesta kaardi

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.