Reputation: 2589
Im new to crispy forms and am trying to use bootstrap to style some form fields into a bootstrap panel, then I will add some other fields into another panel and so on. Building the first panel I am getting the below error.
something is awry but am not sure what?
Traceback:
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
41. response = get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _legacy_get_response
249. response = self._get_response(request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "/usr/local/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
23. return view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
23. return view_func(request, *args, **kwargs)
File "/itapp/itapp/sites/views.py" in edit_site
829. from sites.forms import EditSiteForm
Exception Type: SyntaxError at /sites/edit/7
Exception Value: positional argument follows keyword argument (forms.py, line 53)
this is my forms.py
class EditSiteForm(forms.ModelForm):
class Meta:
model = SiteData
fields = ['location', 'site_type', 'bgp_as', 'opening_date','last_hw_refresh_date','is_live',
'tel','address','town','postcode',
'regional_manager','regional_manager_tel','assistant_manager','assistant_manager_tel' ,'duty_manager','duty_manager_tel']
def __init__(self, *args, **kwargs):
super(EditSiteForm, self).__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.form_id = 'edit_site_form'
self.helper.form_method = 'POST'
self.helper.add_input(Submit('submit', 'Save', css_class='btn-primary'))
self.helper.layout = Layout(
Div(title='', css_class='panel panel-primary',
Div(title='Details', css_class='panel-heading'),
Div(css_class='panel-body',
Field('location', placeholder='Location'),
Div('site_type', title="Site Type")
),
)
)
this is the line its complaining about
Div(title='Details', css_class='panel-heading'),
Upvotes: 1
Views: 361
Reputation: 9076
I think it's really complaining about this:
Div(css_class='panel-body',
Field('location', placeholder='Location'),
Div('site_type', title="Site Type")
),
You are passing two positional args (Field
, and Div
) after a keyword argument (css_class
).
You can fix this by re-arranging:
Div(
Field('location', placeholder='Location'),
Div('site_type', title="Site Type")
css_class='panel-body',
),
Upvotes: 1