M
M
ma3xak2018-05-05 21:56:02
Django
ma3xak, 2018-05-05 21:56:02

Why is the form not rendering?


Doesn't render the views form

def contact_Form(request):
  if request.method == "POST":
    form = contactForm(request.POST)		
    return render(request, 'about/about.html', {'form':form})

fomrs
class contactForm(forms.ModelForm):
  class Meta:
    models = contact
    fields = ('name', 'email', 'text')

model
class contact(models.Model):
  name = models.CharField(verbose_name = "Имя", max_length=60, blank=True, default=None)
  email = models.EmailField()
  text = models.TextField(blank=True, default=None)

Sample
<div class="div">
                {{ form.as_p }}
            </div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Sergeev, 2018-05-06
@SergeevAI

After 'aboutPost5': ...
Add 'form': contactForm.
Also google "PEP8" and read.
One more thing. If you are assigning variables aboutPost1-5 then you are doing something wrong. Add a field to the model that will combine all these records, and filter by it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question