Then, tutorials will have a foreign key that point to the series they belong to, and series will point to a specific category, and this is how we have relationships between tables. Let's see how this works. For example if the category is "Data Analysis," then what's the URL that will point to this category, should a user click on the "Data Analysis" card.
Next, we'll make another model TutorialSeries , which will have a foreign key that points to the TutorialCategory model. Basically, we need to know what to do with the referenced objects when the main one is deleted. If the category gets deleted, then the tutorials that have that category will have their categories set to their default values rather than deleted.
Asked 10 years, 2 months ago. Active 10 years, 2 months ago. Viewed 6k times. Any suggestions? Improve this question. Daniel Roseman k 57 57 gold badges silver badges bronze badges.
Asif Asif 1 1 gold badge 6 6 silver badges 9 9 bronze badges. Add a comment. This redirect is achieved by means of reverse function. This is a guide to Django Reverse. Here we discuss the introduction, How reverse function works? You may also have a look at the following articles to learn more —. Submit Next Question. By signing up, you agree to our Terms of Use and Privacy Policy.
Forgot Password? This website or its third-party tools use cookies, which are necessary to its functioning and required to achieve the purposes illustrated in the cookie policy.
By closing this banner, scrolling this page, clicking a link or continuing to browse otherwise, you agree to our Privacy Policy. The Student model is referencing the Teacher model. Two fields of the Student model are referencing the Teacher model. Otherwise, Django will throw an exception. We have a teacher whose id is 1. If we have to get all the students who have this individual as their class teacher, we will do the following:.
The teacher.
0コメント