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 6740459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:36:31+00:00 2026-05-26T11:36:31+00:00

I have these models: class Tour(models.Model): Name=models.CharField(max_length=100) Count=models.SmallIntegerField() PriceUnitCode=models.ForeignKey(PriceUnit) Price=models.CharField(max_length=12) Description=models.TextField() ActionDate=models.DateTimeField(auto_now=True,editable=False) ActionUserCode=models.ForeignKey(User,editable=False) StatusTypeCode=models.ForeignKey(StatusType)

  • 0

I have these models:

class Tour(models.Model):
   Name=models.CharField(max_length=100)
   Count=models.SmallIntegerField() 
   PriceUnitCode=models.ForeignKey(PriceUnit)
   Price=models.CharField(max_length=12)
   Description=models.TextField()
   ActionDate=models.DateTimeField(auto_now=True,editable=False)
   ActionUserCode=models.ForeignKey(User,editable=False)
   StatusTypeCode=models.ForeignKey(StatusType)

class Images(models.Model):
   Image = models.ImageField(upload_to="gallery")
   Tour=models.ForeignKey(Tour)   

I wanna design a form to add a tour and a set of Images for that Tour at the same form.
this is my FormModel:

class TourForm(ModelForm):
   class Meta:
       model = Tour

I do this in views.py :

def myview(request,key):  
    GalleryFormSet = inlineformset_factory(Tour,Images)   
    if request.method == 'POST':        
        form = TourForm(request.POST, request.FILES)
        if form.is_valid():
            tour=form.save()
            formset=GalleryFormSet(request.POST, request.FILES,instance=tour)
            if formset.is_valid():
                formset.save()
    else:
        form = TourForm()
        formset=GalleryFormSet()
    return render_to_response('airAgency/addtour.html', {'form': form,'formset':formset})

in my template :

<form method='POST' enctype="multipart/form-data" dir="rtl">
    {% csrf_token %}
    {{ form.as_p }}
    {{ formset.management_form }}
    {% for form in formset %}
        {{ form }}
    {% endfor %}
    <input type="submit" />
</form>   

but it has this error:

unexpected indent (views.py, line 122) 

line 122 is this :

if(form.is_valid()):

of course I changed this code alot,but every time it has error in line 122 while the code in line 122 is changing every time!!!
what’s wrong with it?!!!
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-26T11:36:31+00:00Added an answer on May 26, 2026 at 11:36 am

    Very likely, your indentation differs in line 122, most probably because you have invisible differences in leading whitespace.

    Example: You have many lines in a block, all start with a tab, which is displayed by your editor as … 8 spaces. One of the lines (line 122) contains a space and a tab as leading whitespace, which is displayed by your editor as … 8 spaces. You do not see the difference, yet, the line start is different for Python, and that is the problem.

    Advice: Remove all leading space from line 122, then autoindent it with your editor to get consistent results. Or remove all leading whitespace from line 122 and use the same start as the rest of the block.

    To verify this is the case, open your file with ViM, and type :set list (all characters). Now TAB will be displayed as ^I, while space will be displayed as a single space character.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have these models: class Person(models.Model): name=models.CharField(max_length=100) family=models.CharField(max_length=100) class MailContact(models.Model): person=models.ForeignKey(Person) email=models.CharField(max_length=100) #some fields
I have these 2 models: class Agency(models.Model): Location=models.ForeignKey(Location) Name=models.CharField(max_length=50) WebSite=models.CharField(max_length=100) class AgencyPosition(models.Model): Agency=models.ForeignKey(Agency) Users=models.ManyToManyField(User)
I have these models: class App(models.Model): name = models.CharField(max_length=100) class ProjectA(models.Model): name = models.CharField(max_length=100)
I have these Django models: class Group(models.Model): name = models.CharField(max_length=100) parent_group = models.ManyToManyField("self", blank=True)
I currently have these models: class Category(models.Model): name = models.CharField(max_length=200) parent = models.ForeignKey('self', blank=True,
I have these models set up in Django: class SourceBusiness(models.Model): source = models.CharField(max_length=100) ...(other
I have these models: class Supplier(models.Model): name = models.CharField(max_length=50) def __unicode__(self): return u"%s" %
I have these models: class Projects(models.Model): projectName =models.CharField(max_length = 100,unique=True,db_index=True) projectManager = EmbeddedModelField('Users') class
I've got these models in my Django project: class Area(models.Model): name = models.CharField(max_length=100, primary_key=True)
I have these 3 models in models.py class Customer(models.Model): name = models.CharField(max_length=50) .... class

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.