The CreateView page doesn't take into account the form

I tried to create in Django an create view , to use form and it doesn't work. The program doesn't use form. I don t understand why the form doesn t work.

from django.urls import path

from .views import (

urlpatterns = [
    path(r'', ItemListView.as_view(template_name='item_list.html'), name='ListView'),
    path(r'create/', ItemCreateView.as_view(), name='create'),
    path(r'<int:pk>/', ItemDetailView.as_view(), name='s'),

class Item(models.Model):
    user        =models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
    article     =models.ForeignKey(Article, on_delete=models.CASCADE)
    #item stuff
    name        =models.CharField(max_length=120)
    description =models.TextField(blank=True, null=True, help_text='Separate each item by comma')
    exceptions  =models.TextField(blank=True, null=True, help_text='Separate each item by comma')
    bl          =models.BooleanField(default=True)
    timestamp   =models.DateTimeField(auto_now_add=True)
    updated     =models.DateTimeField(auto_now=True)

    def get_absolute_url(self):
        return reverse('menus:s', kwargs={'pk'})

    class Meta:
        ordering = ['-updated','-timestamp']
    def get_description(self):
        return self.description.split(',')
    def get_exceptions(self):
        return self.exceptions.split(',')

class ItemCreateView(CreateView):
    template_name = 'menus/form.html'
    form_class = ItemForm
    def get_queryset(self):
        return Item.objects.filter(user=self.request.user)
    def get_context_data(self,*args, **kwargs):
        context=super(ItemCreateView, self).get_context_data(**kwargs)
        title='Add Item'
            'title' : title

    def form_valid(self, form):
        instance =
        instance.user = self.request.user
        return super(ItemCreateView, self).form_valid(form)

from django import forms
from .models import Item

class ItemForm(forms.ModelForm):
    class Meta:

        model = Item
        fields = [


{% extends 'main\base.html' %}
{% block content %}
<p>{{ title }}</p>
{% if form.errors.non_field_errors %}{{ form.errors.non_field_errors }}{%endif%}
<form method="POST"> {% csrf_token %}
    {{ form.as_p }}
    <button type="submit">Save</button>
{% endblock content %}

The result is: enter image description here

I don't understand why it doesn't take the for in html.

Back to Top