1👍
from django import SearchForm
ImportError: cannot import name ‘SearchForm’
The updated error is because you are trying to import the SearchFrom from the root of the django library.
You need to import your SearchForm
from your app, so in your views.py
from django import SearchForm
should be something like
from myapp.form import SearchForm
Also, in Django it is common to call your forms containing file forms
(plural) instead of form
(singular), since it can contain multiple forms.
0👍
The SearchForm is in your django app and not in your django library.
Use from .form import SearchForm
Also, move your else to ( if request.method == POST ), so that the form is sent if method is not post.
And I would suggest you to use reverse() function to resolve url ,
HttpResponseRedirect(reverse(‘search’))
- MultipleChoiceField on multiple columns
- Accessing request object in a SessionWizardView in django
- Django with jquery-fileupload ui throws error with "This field is required."
- Django + postgres: orderby + distinct + filter() – strange behaviour
- Django LDAP authn backend: user authenticated but unable to login
Source:stackexchange.com