November 2015
Beginner to intermediate
840 pages
26h 30m
English
Tag Objects to Post InstancesIn this section, we implement a signal handler to assign Tag objects to Post instances whenever a Post and Startup are related.
A Post may be related to a Startup in various ways, as shown in Example 25.9.
Example 25.9: Python Code
post_object.startups.add(startup_object1, startup_object2) startup_object.blog_posts.add(post_object1, post_object2)
Even though a many-to-many relationship is symmetric (if you are someone’s friend, then they are also your friend), Django defines the first relation as the forward relation, while the second is the reverse relation. Django uses this definition in our signal handler, too.
To start, we need to import our tools, ...
Read now
Unlock full access