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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:29:45+00:00 2026-05-16T15:29:45+00:00

I dont understand how I can import(I dont know the right terminology, so please

  • 0

I dont understand how I can “import”(I dont know the right terminology, so please dont crucify me on this) a Foreignkey from 1 model class to a another:

e.g.

class1 (models.Model):
    variable1 = models.CharField()
    variable2 = models.CharField()

class2 (models.Model):
    variable3 = models.CharField()
    variable4 = class1.variable1 "imported" from class1

So now I have all the data from variable1 from class1 available in class2.

I assume this would be accomplished by a ForeignKey.

If I take the example of the official Django documentation (see below), I dont get my answer because:

  1. Why does it only mention the other model and not the variable I create from it.

  2. This would be for a future model, where I dont know the fields yet. But i know the fields already. Again no variable, just the model.

  3. This would be what I am looking for. But this is “imported” from another app. But with me it is in the same app.

ad 1.

class ForeignKey(othermodel[, **options])¶

ad 2.

class Car(models.Model):
    manufacturer = models.ForeignKey('Manufacturer')
    # ...

class Manufacturer(models.Model):
    # ...

ad 3.

class Car(models.Model):
    manufacturer = models.ForeignKey('production.Manufacturer')

Thanks!

  • 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-16T15:29:46+00:00Added an answer on May 16, 2026 at 3:29 pm

    If I understand your question correctly.

    You are establishing the relationship to the whole model with a foreign key, not just one field, so you will have access to all the fields, even if you only want one.

    variable4 = models.ForeignKey(class1)

    now you can say variable4.variable1 or variable4__variable2 in a queryset.

    Re point 2 – use variable4 = models.ForeignKey(‘class1’) if class1 not already defined
    Re point 3 – no need to add application if model in the current application.

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

Sidebar

Related Questions

I don't understand why I can't find a solution for this, since I feel
I don't understand the need for self-joins. Can someone please explain them to me?
I can't get this to work, and don't understand where the error would be
I know this sounds like something I can google, but the truth is that
I was solving this problem6 , I dont even know the answer but, when
My code snippet look like this: from time import sleep for i in xrange(10):
When I try to run this code: import java.io.*; import java.util.*; public class TwoColor
I'm don't understand how we can positioning objects with opengl. All transformation values is
I don't understand where to put the Resources and how can we take the
I don't understand why in the url_split function I can use a++ , but

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.