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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:48:41+00:00 2026-05-26T12:48:41+00:00

Given an example like this: class MyForm(forms.Form): name = forms.CharField() I’m trying to grasp

  • 0

Given an example like this:

class MyForm(forms.Form): 
    name = forms.CharField()

I’m trying to grasp what the difference between the following two snippets is:

“Bound Data” style:

my_form = MyForm({'name': request.user.first_name})

“Initial data” style:

my_form = MyForm(initial={'name': request.user.first_name})

The documentation seems to suggest than “initial is for dynamic initial values”, and yet being able to pass “bound data” to the constructor accomplishes exactly the same thing. I’ve used initial data in the past for dynamic values, but I’m tempted to use the more straightforward “bound data” style, but would like some insights about what the real difference between these two styles is.

  • 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-26T12:48:41+00:00Added an answer on May 26, 2026 at 12:48 pm

    Here’s the key part from the django docs on bound and unbound forms.

    A Form instance is either bound to a set of data, or unbound:

    • If it’s bound to a set of data, it’s capable of validating that data and rendering the form as HTML with the data displayed in the HTML.
    • If it’s unbound, it cannot do validation (because there’s no data to validate!), but it can still render the blank form as HTML.

    You can’t really see the difference for the example form you gave, because the form is valid in the "bound data" style. Let’s extend the form by adding an age field, then the difference will be more obvious.

    class MyForm(forms.Form):
        name = forms.CharField()
        age = forms.IntegerField()
    

    Bound form

    my_form = MyForm({'name': request.user.first_name})
    

    This form is invalid, because age is not specified. When you render the form in the template, you will see validation errors for the age field.

    Unbound form with dynamic initial data

    my_form = MyForm(initial={'name':request.user.first_name})
    

    This form is unbound. Validation is not triggered, so there will not be any errors displayed when you render the template.

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

Sidebar

Related Questions

I'm trying to solve this problem : http://uva.onlinejudge.org/external/7/732.html . For the given example, they
Given this example: <img class=a /> <img /> <img class=a /> <img class=a id=active
Given that my class looks like this: class Methods{ function a(){ return 'a'; }
When I have a given django model class like this: class BaseClass(models.Model): some_field =
Example: I have a selector like this, which I give to another method as
In most languages like C# for example given a string you can test (boolean)
For example, given a type param method i'm looking for something like the part
Given any iterable, for example: ABCDEF Treating it almost like a numeral system as
I have Java classes like this: public class Config { public Config1 getConfigOpt1(); public
I have a class (simplified example) like : public class SomeCollection : ICloneable {

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.