I am trying to create a modal form in my django project. I am trying to use bootstrap modal forms and I am following an example:
https://pypi.org/project/django-bootstrap-modal-forms/
When I import in views.py:
from bootstrap_modal_forms.generic import BSModalCreateView
I get an error "cannot import name LoginView" - but I'm confused because I do not have LoginView anywhere in my project. Why is this happening? This is my first time trying to use Class Based Views. I know this isn't a lot of detail, but I am completely confused here.
views.py
from django.urls import reverse_lazy
from .forms import BookForm
from .models import Book
from bootstrap_modal_forms.generic import BSModalCreateView
class BookCreateView(BSModalCreateView):
template_name = 'examples/create_book.html'
form_class = BookForm
success_message = 'Success: Book was created.'
success_url = reverse_lazy('index')
forms.py
from .models import Book
from bootstrap_modal_forms.forms import BSModalForm
class BookForm(BSModalForm):
class Meta:
model = Book
fields = ('title', 'author', 'price')
You are using a version of Django (1.10) that is incompatible with the version of bootstrap_modal_forms
that you have installed. bootstrap_modal_forms
is attempting to import django.contrib.auth.views.LoginView
, which was only added in Django 1.11.
You will need to upgrade to at least Django 1.11 if you want to use bootstrap_modal_forms
. You should probably do this anyway given that 1.10 reached end of life a long time ago, and not secure.