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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:23:40+00:00 2026-05-17T01:23:40+00:00

I am a bit stuck on how I should model this out. Here is

  • 0

I am a bit stuck on how I should model this out.

Here is what I have:

I have a model called Location. In this model I have postal code, city, region, longitude, and latitude. This data is pre-populated with all of Canada’s stuff. You can imagine this table is quite large.

This is what I would like to achieve by stuck on how to model this:

I would like to create a second model called Item. Each one of these items will need to be tied to a location from the said above model. The user-story would be as follows:

User adds an item: I already know their postal code and city based on their cookie that I set.
User submits the form with their item: this is where I am confused as to how to model this data so that the item gets saved in the proper location.

I figured a FK would be the way to go but that is waaaaay to inefficient for a number of obvious reasons (huge list, and requires user input but I already know their location before saving). So, since I already know their location based on their cookie, should create a new field in the Item model called location and just save the postal code in this model? If I did this I guess I would have to query the location model for that location to pull in proper info. I am not sure what the best to go about this is, please help.

  • 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-17T01:23:40+00:00Added an answer on May 17, 2026 at 1:23 am

    If you already know the user’s location, and they’re just entering an item, then the Item model should have a foreign key to Location, but you don’t prompt for it on the form. Instead, fill in the Location before you save the item.

    If you’re using a ModelForm, then you’ll want to exclude your location field so that it isn’t displayed. You’ll also want to set commit=False so that you can fill in the location yourself before saving the form data to the Item table.

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

Sidebar

Related Questions

I'm a bit stuck with my code: def setVenueImage(img): img = images.Image(img.read()) x, y
I've come a bit stuck this afternoon with a bug in my web application
I'm a bit stuck on this - I am using a Wordpress shortcode with
hi i am a bit stuck with this. what i am going to work
I haven't implemented a search feature before and feel a bit stuck. I have
I'm creating a tableless Rails model, and am a bit stuck on how I
I'm working on learning Objective-C/Coaoa, but I've seem to have gotten a bit stuck
I would like to ask you this question because I am a bit stuck
I've been reading up a bit about coffeescript's inheritance model and I have the
I am stuck on the following issue: I have a model with a property

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.