How to exclude django form field from render but still keep it for validation?

前端 未结 4 507
悲&欢浪女
悲&欢浪女 2021-01-19 17:42

If I have a model (extract):

class Coupon(models.Model):
    image = models.ImageField(max_length=64, null=True, upload_to=\"couponimages\")
<
4条回答
  •  深忆病人
    2021-01-19 17:47

    You can render form manualy like this:

    in views.py

    return render(request, 'template.html', {'form': form})
    

    in template.html

    {% csrf_token %} {{ form.field1 }} {{ form.field2 }} . . .

    also take a look to Working with forms.

提交回复
热议问题