Monday, February 29, 2016

Re: Absolute beginner question -- recipes

On 28/02/16 20:14, Simon Gunacker wrote:
> |
> def detail(request, pk):
> recipe = Recipe.objects.get(id=pk)
> recipe['steps'] = Steps.objects.filter(recipe_id=pk)
> template = loader.get_template('recipe/recipe_detail.html')
> context = {
> 'recipe': recipe,
> }
> return HttpResponse(template.render(context,request))
> |

OT:
Have a look at the render shortcut:
https://docs.djangoproject.com/en/1.9/topics/http/shortcuts/#render

| return render(request, 'recipe/recipe_detail.html', context)

Maybe you can simply use a generic DetailView:
https://docs.djangoproject.com/es/1.9/ref/class-based-views/generic-display/#detailview

--
Florian

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/56D44106.1070704%40ist-total.org.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment