question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Parameter "form" should contain a valid Django Form

See original GitHub issue

I followed the example using Parameter Django (2.0) and django-bootstrap3 (9.1.0) and it shows: `

Request Method: GET
http://127.0.0.1:8000/polls/
2.0
BootstrapError
Parameter “form” should contain a valid Django Form.
D:\PycharmProjects\mysite\venv\lib\site-packages\bootstrap3\renderers.py in init, line 161
D:\PycharmProjects\mysite\venv\Scripts\python.exe
3.5.1
[‘D:\PycharmProjects\mysite’, ‘D:\PycharmProjects\mysite\venv\Scripts\python35.zip’, ‘D:\PycharmProjects\mysite\venv\DLLs’, ‘D:\PycharmProjects\mysite\venv\lib’, ‘D:\PycharmProjects\mysite\venv\Scripts’, ‘C:\Python\Python35\Lib’, ‘C:\Python\Python35\DLLs’, ‘D:\PycharmProjects\mysite\venv’, ‘D:\PycharmProjects\mysite\venv\lib\site-packages’]
Sun, 17 Dec 2017 15:35:23 +0800
`
following is my code:

` {% load static %}

{# Load the tag library #} {% load bootstrap3 %}

{# Load CSS and JavaScript #} {% bootstrap_css %} {% bootstrap_javascript %}

{# Display django.contrib.messages as Bootstrap alerts #} {% bootstrap_messages %}

<link rel="stylesheet" type="text/css" href="{% static 'polls/style.css' %}" /> <form action="/url/to/submit/" method="post" class="form"> {% csrf_token %} {% bootstrap_form form %} {% buttons %} <button type="submit" class="btn btn-primary"> {% bootstrap_icon "star" %} Submit </button> {% endbuttons %} </form> `

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
christenviecommented, Aug 21, 2020

The issue is with the context you are passing

when you are rendering the view in the views.py there needs to be a context with a form as a dictionary such as this

context = {‘form’:form} return render(request, ‘learning_logs/upgrade.html’, context)

without a context there will be no form passed to the function handling the request

0reactions
stale[bot]commented, Nov 13, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

BootstrapError Parameter "form" should contain a valid ...
I would guess this is an error with django-bootstrap using the custom TextArea widget; I added a suggestion for how I would investigate...
Read more >
Parameter "form" should contain a valid Django Form-django
Coding example for the question BootstrapError: Parameter "form" should contain a valid Django Form-django.
Read more >
Form and field validation
The validate() method on a Field handles field-specific validation that is not suitable for a validator. It takes a value that has been...
Read more >
Python – BootstrapError Parameter “form” should contain a ...
Now, the error your seeing is most likely related to you passing request.POST to a form even if request.POST is blank; the form...
Read more >
Template tags and filters - django-bootstrap4 - Read the Docs
Render form errors. Tag name: bootstrap_form_errors. Parameters: form The form that is to be rendered type Control which type of errors should be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found