5.8.3 Building a Startup Detail Page

As we did for our tag_detail() view, we will now build a startup_detail() view. The function will show a single Startup object, directed to in the URL by the slug field of the model. Our function view thus must take not only a request argument but also a slug argument. In /organizer/views.py, enter the code shown in Example 5.45.

Example 5.45: Project Code

organizer/views.py in bb3aa7eb88

 7  def startup_detail(request, slug):  8      startup = get_object_or_404(  9          Startup, slug--iexact=slug) 10      return render( 11          request, 12          'organizer/startup_detail.html', 13          {'startup': startup})

As before, we use the slug value passed by the URL configuration ...

Get Django Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.