O'Reilly logo

Django Unleashed by Andrew Pinkham

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

18.8.2 Automating Startup Selection in NewsLink Forms

To create a new NewsLink object, a user will first browse to a Startup’s detail page and then click the Add Article link to be brought to the NewsLinkCreate view. The form will promptly ask the user which Startup he or she would like to create a NewsLink for. That’s really silly, not only because we just came from the Startup we want to create a NewsLink for but also because the slug of the Startup is now in the URL!

There are two ways to fix this problem. In the first, we automatically infer the Startup without any outside intervention. In the second, we use a hidden field on the form to submit the slug of the Startup to the form.

18.8.2.1 Inferring the Startup

The slug of the Startup we ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required