yceruto/django-ajax

class based view (CreateView) with AJAXMixin

khaldon opened this issue · 5 comments

the error is This page isn’t working and HTTP ERROR 400 in the terminal show me Bad request

Hi @khaldon, I'll take a look at this class, meanwhile could you show me the whole errors trace?

Could you show me how this class definition looks like? For example, this is how I tried it:

class SimpleView(AJAXMixin, TemplateView):
template_name = 'hello.html'

this the code
screenshot from 2019-02-18 16-37-10
this error
screenshot from 2019-02-18 16-38-28

Are you accessing to this URI through a non-AJAX call?

By default it's mandatory, but you can make it optional by configuring ajax_mandatory manually:

class CreatContact(AJAXMixin, CreateView):
    # ...
    ajax_mandatory = False

So this is not a bug, but a usage issue, thanks for reporting it, I'll try to update the docs to make it clear.

Thank you , that's work well. but I want to know how about dealing with Template and recieve or fetch data from model that automatic work or what will happen ?