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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:29:21+00:00 2026-06-13T17:29:21+00:00

lately I found a weird behavior in Django. Then, I start thinking that what’s

  • 0

lately I found a weird behavior in Django. Then, I start thinking that what’s wrong is the way I’m doing the work.

Lets assume that we have 2 models

class A(models.Model):
    attr1 = models.CharField()
...

class B(models.Model):
    a = models.ForeignKey("A",
        related_name = "bs"
        blank = True,
        null = True)

So, if I have some items of B, without associations to A, say b1, b2, b3, when I set a new instance of A, say a1, if I query

a.bs.all()
b1, b2 and b3 are returned.

What’s wrong with it? When I create a new instance, it should not rise any relation. I know that b1,b2 and b3 have no relations, but they can’t be associated by default to any new instance.

Anyone know how to proceed in a Django way?

I know I can do the trick
if a1.id:
return []
else:
a1.bs.all()

But I think that’s not the right way to do this.

Can anyone help me?

Thank you 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-13T17:29:23+00:00Added an answer on June 13, 2026 at 5:29 pm

    This is a bug in Django and is currently marked as “design decision needed”:

    https://code.djangoproject.com/ticket/14615

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

Sidebar

Related Questions

I' ve been doing some programming lately and faced an issue which i found
I've been experimenting with HTML5 lately, and found it of interest that when adding
I have been doing some Windows Assembly Language programming lately and I realized that
I've been working with FParsec lately and I found that the lack of generic
Something I have found myself doing often lately is declaring typedefs relevant to a
Concerning pages that build a web application: Lately, I have found myself creating web
This is something that has been troubling me lately, and i've found related questions
I have been playing with NodeJS lately and i found myself stuck with a
Lately, I've often found myself wanting to run some command on the output of
Lately I've been thinking a lot about building a website/blog/community oriented site. However I

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.