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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:03:09+00:00 2026-05-31T09:03:09+00:00

I am a newbie to Django, GAE, and met some problems when I am

  • 0

I am a newbie to Django, GAE, and met some problems when I am trying to build some dynamic forms using Django. The idea is that the selection made from one drop-down box determines value in another field.

In detail, if an user

  1. choose “A” in “Species”, then the value in the “body_weight” will be 178. Similarly,
  2. if he choose “B” in “Species”, the value in “body_weight” is 1580, and
  3. if choose “C” in “Species”, the he can fill in the “body_weight”

I read some examples, and found some features like “init, and super should be included”. Thus I modified my codes, but it still did not work.

My problems are:

  1. What is the right position to place “init” and “super”?
  2. Do I need “self.field” here?

All suggestions are welcomed!

Thanks!

Here is the code.

Species_CHOICES=(('178','A'),('1580','B'),('','C'))

class Inp(forms.Form):
    Species = forms.ChoiceField(label='Species', choices=Species_CHOICES, initial='A')

    #Here detect the choice made by the user
    def get_STB_choices(Species):
        if Species=='178':
            r= 178
        elif Species=='1580':
            r= 1580
        else:
            r= 4440
        return a

    #assign values to a new parameter based on user's choice 
    def __init__(self, *args, **kwargs):
        super(Inp, self).__init__(*args, **kwargs)    
    body_weight=forms.FloatField(required=True, label='Body weight', initial=get_STB_choices(Species))


#write out in HTML
class InputPage(webapp.RequestHandler):
    def get(self):
        html = str(Inp())
self.response.out.write(html)
  • 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-31T09:03:10+00:00Added an answer on May 31, 2026 at 9:03 am

    You’re going to need Javascript running on the page to update the available selections.

    I implemented it one way here. Each time you make a selection, the page makes an AJAX request to get the new form fields that were dependent on the initial change.

    https://github.com/dragonx/django-hier-ajax-form

    After I did mine, I realized there was already an existing project that did the same thing, but our implementations are pretty different:

    https://github.com/digi604/django-smart-selects

    btw, I believe usually when you call super() you use it with the name of the current class, so I would have expected

    super(Inp, self).__init__(*args, **kwargs)    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Django newbie at work and I could use some pointers. I'm using django-profile and
i'm a newbie django developer, trying to build demo pages for my cpp and
Django and programming newbie with a question about how to build a dynamic form.
Newbie question. I have Django models that look like this: class Video(models.Model): uploaded_by =
Django newbie here, I'm using render_to_response('example.html', { 'error_message': error_message, }, context_instance=RequestContext(request)) How do I
I'm a Django newbie who needs help: Even though I change some urls in
I am a python django newbie, and was going through some open source code,
Django newbie question.... I'm trying to write a search form and maintain the state
Django newbie here stumbling my way around the docs. I'm trying to create a
Python and django newbie question, here is code: class Client(User) #some fields client=Client() client.save()

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.