Template With a Form

Report a typo

We have a model Drink with fields brand, taste:

class Drink(models.Model):
    brand = models.CharField(max_length=32)
    taste = models.CharField(max_length=32)

We pass an instance of the model to a template in context dictionary: {'drink': ...}.

Add the id of a drink to the value of an "input" element and a CSRF token at the beginning of the form.

Write a program in Python 3
template = """
<form action="post">
<input type="hidden" name="drink_id" value=???>
<button type="submit">Order it!</button>
</form>
"""
___

Create a free account to access the full topic