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

  • Home
  • SEARCH
  • 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 8321491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:02:11+00:00 2026-06-08T23:02:11+00:00

I have a Person model which have a relationship with a City model: class

  • 0

I have a Person model which have a relationship with a City model:

class Person(models.Model):
    ...
    state = models.CharField(max_length=2, choices=STATES)
    city = models.ForeignKey('City')

class PersonForm(ModelForm):
    ...
    class Meta:
        model = Person

class City(models.Model):
    name = models.CharField(max_length=200)
    state = models.CharField(max_length=2)

I am using a ModelForm to render the Person form in the template, through the as_p attribute.

I have a pre-loaded set of data for the City database (it is a huge set of data in the DB), and I don’t wan’t that data to be loaded into a select list in the form created to include Person.

Is there any way to avoid that set of data being loaded in the html, using ModelForm and the as_p attribute?

Thanks in advance!

  • 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-08T23:02:13+00:00Added an answer on June 8, 2026 at 11:02 pm

    Ofcourse, you can overwrite any field or any widget, have a look, the django documentation is pretty clear on this:

    modelform

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

Sidebar

Related Questions

I have a symmetrical many-to-many relationship in Django class Person(models.Model): id = models.CharField(max_length=32, primary_key=True)
I have the following models class Person(models.Model): name = models.CharField(max_length=100) class Employee(Person): job =
Hay, I have a Model which looks like this class Person(models.Model): name = models.CharField(blank=False,
I have a simple Django model like: class Person(models.Model): referrer = models.ForeignKey('self', null=True) ...
I have a model in my rails application which is class Person < ActiveRecord::Base
Suppose I have a model Person which has a one to many relationship with
Say I have a model object 'Person' defined, which has a field called 'Name'.
I have two models: Person and Address which I'd like to create in a
I have a model called Person. I want User to inherit from Person. class
So I have the following model: public class Person { public String FirstName {

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.