November 2015
Beginner to intermediate
840 pages
26h 30m
English
NewsLink Objects in a View with NewsLinkFormIn most respects, NewsLinkCreate is identical to our other object creation views. However, the post() method in NewsLinkCreate comes with an interesting quirk. Ignoring the difference in variable names (new_newslink instead of new_startup), we find ourselves unable to use redirect() in the same way as we previously did. That makes sense: Django convention only allows for this behavior because a model has a get_absolute_url() method. The problem is that our NewsLink class doesn’t! We could circumvent by redirecting to the page the NewsLink is displayed at: the Startup page, causing Django to call the get_absolute_url() method of the Startup object pointed to by our new NewsLink object. ...
Read now
Unlock full access