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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:40:56+00:00 2026-05-30T05:40:56+00:00

So I have a few Django models that look like this: class City(models.Model): name

  • 0

So I have a few Django models that look like this:

class City(models.Model):
   name = models.CharField("City", max_length=200)

   def __unicode__(self):
     return self.name

   class Meta:
     verbose_name_plural="Cities"

 class Neighborhood(models.Model):
   name = models.CharField("Neighborhood", max_length=200)
   city = models.ForeignKey(City, verbose_name='City')

   def __unicode__(self):
     return self.name + " in " + str(self.city)
 class Application(models.Model):
   NUM_BED_CHOICES = ((1, u'Rollin Solo'), (2, u'2 Bedrooms'), (3, u'3 Bedrooms'), (4, u'4 Bedrooms'),)
   LEASE_LENGTH_CHOICES = ((u'SUM', u'Summer'), (u'1YR', u'One Year'), (u'2YR', u'Two Years'), (u'2Y+', u'Two Years+'),)

   user = models.ForeignKey(User)
   neighborhood = models.ForeignKey(Neighborhood, verbose_name="Neighborhood")
   moveinDate = models.DateField("Move-in Date")
   numberOfBedrooms = models.SmallIntegerField("Number of Bedrooms", choices=NUM_BED_CHOICES)
   leaseLength = models.CharField("Lease Length", max_length=3, choices=LEASE_LENGTH_CHOICES)
   bedroomBudget = models.DecimalField("Budget Per-Bedroom", max_digits=10, decimal_places=2)
   hasPet = models.BooleanField("Has Pet")
   hasBeenPlaced = models.BooleanField("Has Been Placed", default=False)

   class Meta:
     verbose_name = "Application"

And I have a Model Form for the Appliction, that’s just this:

class ApplicationForm(ModelForm):
  class Meta:
    model = Application
    exclude = ('hasBeenPlaced','user',)

I’d like to be able to add a selection widget to my ApplicationForm that allows the users to select from one of the City Objects in my City model, and then filter their choices of neighborhoods based on that selection. For example: if they select ‘Chicago’ in this extra field I want to add, all of the neighborhoods that weren’t in Chicago would be removed from the list of available neighborhoods to select from in the ApplicationForm. Is this possible with Django? If so, how would one go about accomplishing such a task?

  • 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-30T05:40:56+00:00Added an answer on May 30, 2026 at 5:40 am

    Technically, this is no longer in the realm of Django. Once the page is rendered, Django is done. Anything like this requires JavaScript and specifically AJAX. You just create a view to return neighborhoods for a city in JSON, then use AJAX to fetch that response whenever the city selectbox’s onchange event is fired. Use use the JSON to construct new options for the neighboorhood selectbox, and then replace the old options with that.

    There’s a million questions on StackOverflow regarding how to specifically do all that — many written by myself.

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

Sidebar

Related Questions

I have few similar models in Django: class Material(models.Model): title = models.CharField(max_length=255) class Meta:
Please see the following Django models: - class Student(models.Model): reference_num = models.CharField(max_length=50, unique=True) name
I have a simple Django model like: class Person(models.Model): referrer = models.ForeignKey('self', null=True) ...
Hi i am using django 1.2 .I my case i have few models which
I'm writing a Django-ORM enchancement that attempts to cache models and postpone model saving
I have a few models in Django where I attach a location to each
I have an existing Django application with a pretty typical model implementation that's backed
I am exploring Django with MySQL & have a few things that I wanted
I have few different applications among which I'd like to share a C# enum.
I have few question in this regard When you create an internet page, does

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.