I have a ModelForm
with a FilteredSelectMultiple
widget
from django import forms
from django.contrib import admin
class PortFolioForm(forms.ModelForm):
class Meta:
model = PortFolio
fields = ['title', 'description', 'keywords']
class Media:
css = {'all':['admin/css/widgets.css']}
js = ['/admin/jsi18n/']
keywords = forms.ModelMultipleChoiceField(label='Mots clés', widget=admin.widgets.FilteredSelectMultiple('Mots clés', False), queryset=Keyword.objects.all())
I'm using the form outside the admin, inside a view
c = {'form': PortFolioForm() }
return render(request, 'portfolio.html', c)
......
form = PortFolioForm(request.POST)
if form.is_valid():
form.save()
......
{{ form | crispy }}
When I'm already logged in as admin, the widget is dispayed as normal
If not it does not appear
I get the following js errors :
Refused to execute script from 'http://localhost/admin/login/?next=/admin/jsi18n/' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
Uncaught ReferenceError: interpolate is not defined at Object.init (SelectFilter2.js:38) at SelectFilter2.js:233 at NodeList.forEach () at SelectFilter2.js:231
As the website I'm working on is meant to be used by other users, I would like to use just the widget itself, because all the saving is done within the views, using form.save()