-1

In the url:

https://docs.djangoproject.com/en/dev/intro/tutorial01/#playing-with-the-api

I'm unable to understand this line:

# Display any choices from the related object set -- none so far. >>> q.choice_set.all() 

q is an instance of Question, and no where we have defined the attribute choice_set, so how come it is working ?

1

1 Answer 1

1

Django creates that attribute under the hood for you when you define your models, is part of django to provide that scaffolding to help you with one-to-many and many-to-many relationships, you can read more about it in Accessing related objects.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.