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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:17:50+00:00 2026-05-29T11:17:50+00:00

May be a simple question, but if I have a ModelForm: class ExampleModelForm(forms.ModelForm): class

  • 0

May be a simple question, but if I have a ModelForm:

class ExampleModelForm(forms.ModelForm):
    class Meta:
        exclude = ['username']

When I use the form, I want to inject a username I’ve got from elsewhere, but still want it to go through the validation process. If I use:

instance = ExampleModel(username='Foobar')
form = ExampleModelForm(request.POST, instance=instance)

if form.is_valid():
    form.save()

Does the username ‘Foobar’ go through the same validation as the rest of the fields in the form?

Thanks,

J

  • 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-29T11:17:50+00:00Added an answer on May 29, 2026 at 11:17 am

    No, the form doesn’t even contain the username field if it has been excluded.

    If you want to perform validation on the field through the form, you should modify the POST dictionary.

    post = request.POST.copy()
    post['username'] = 'Foobar'
    
    form = ExampleForm(post)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay this may be a simple question but I have yet to come with
may be too simple groovy question but....please help i have a list like this:
I have what may be a very simple question. I want to process a
This may be a simple question, but I have been Googling for over an
This may seem like a very simple question, but I have been struggling with
This may be a simple C# question but I need a solution. I have
Hy, i have a big question ... it may sound simple but actually it's
I use spring 3.0 and I have a really simple question but didn't find
this may be a simple question but i was wondering, i have an application
May it's very simple question, but I'm stuck here. I have variable val as

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.