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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:53:23+00:00 2026-06-07T00:53:23+00:00

I have a form that I want to be validated before showing it initially.

  • 0

I have a form that I want to be validated before showing it initially. Basically the behavior I’m going for is that when user opens the form, the initial values (pulled from the object instance) are already checked, and if invalid, marked as such with errors attached.

The idea is to have two forms:

def DraftForm(forms.ModelForm):
    class Meta:
        model = Project

def FinalForm(DraftForm):
    def __init__(self, *args, **kwargs):
        super(FinalForm, self).__init__(*args, **kwargs)
        self.fields['text'].required = True

The first one is used when editing a draft, the second is used to checked if all fields required to publish are filled in etc.

I thought something like this in the “edit project” view would work and make the initial form show with errors:

# redirected from some other form, so no POST at this point:
if request.session.get('trying_to_publish', False):
    form = FinalForm(instance=project)
    form.is_valid()
else:
    form = DraftForm(instance=project)
...

but no; full_clean() doesn’t trigger the errors as well. Any ideas?

  • 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-06-07T00:53:26+00:00Added an answer on June 7, 2026 at 12:53 am

    You need the form to be bound. In place of the request object, you can just use an empty dictionary.

    if request.session.get('trying_to_publish', False):
        form = FinalForm({}, instance=project)  
        form.is_valid()
    

    The is_valid() docs help explain this a little (if you knew what you are looking for). The form has to be bound before it can be validated. Even a form that is passed an empty dictionary becomes bound.

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

Sidebar

Related Questions

I have a form that validates the email address and I want to be
I have a form that i want to appear at the top of every
I have a form that i want an administrator to fill out, then click
I have a form that i want to auto populate the last 2 fields
Okay all, I have a form that I want users to fill out. When
I have a small form that I want to have people fill out on
I want to have a Form that can Add or Delete TextFields. I was
I have XML in the following form that I want to parse with PHP
I have this select input in my form that I want to access via
I have a form that needs to be validated only after it has been

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.