I am trying to pass a form to a ListView in django to create a new object
Is there any way to do that? (I know how to do that using def in stead of class)
Im using django 2.0 , python 3.4
This is the ListView:
class CustomerListView(ListView):
template_name = 'customers/table_customers.html'
context_object_name = 'items'
def get_queryset(self):
return Customer.objects.all()
def get_context_data(self, **kwargs):
context = super(CustomerListView, self).get_context_data(**kwargs)
context['form'] = CustomerForm
return context
I can see the form in the page but when i hit "submit" i get a 405 response from the server: "Method Not Allowed (POST): /customers/customer/".
Here is the form:
class CustomerForm(forms.ModelForm):
class Meta:
model = Customer
fields = ['customer_name',
'start_date',
'end_date',
'team',
'status',
'notes',
]