Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8418643
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:23:12+00:00 2026-06-10T02:23:12+00:00

Hi Stackoverflow people, I have trouble to render a crispy form with a class

  • 0

Hi Stackoverflow people,

I have trouble to render a crispy form with a class based view. Everything worked fine when I used the function based views.

As usual I generate forms.py as follows:

from django import forms    
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Div, Submit, HTML, Button, Row, Field
from item.models import Item

class CreateItemForm(forms.ModelForm):
    class Meta:
        model = Item
        exclude = ('user',)

        def __init__(self, *args, **kwargs):
            self.helper = FormHelper()
            self.helper.form_tag = False
            self.helper.form_class = 'form-horizontal'
            self.helper.layout = Layout(
                Fieldset(
                    'Create your item here',
                    'name', 'description', 
                    'save',
                ),
            )
            self.request = kwargs.pop('request', None)
            return super(CreateItemForm, self).__init__(*args, **kwargs)

The view function is very simple and standard:

from django.views.generic.edit import CreateView,
from item.models import Item
from item.forms import CreateItemForm

class ItemCreate(CreateView):
    form_class = CreateItemForm
    model = Item
    template_name = 'item/item_create_form.html' 

and the template follows the minimal instructions as well:

{% extends "base.html" %}
{% load crispy_forms_tags %}
{% block content %}
<h2>Create new Item</h2>
            <form action="." class="crispy form-horizontal" method="post">
                {% crispy form form.helper %}
            </form>
{% endblock %}

My problem is that Django will complain “VariableDoesNotExist at /item/add/, Failed lookup for key [helper] in …”.

Are crispy forms compatible with class based views? How could I hand over the helper information to create the form correctly?

Thank you for your help and suggestions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:23:13+00:00Added an answer on June 10, 2026 at 2:23 am

    constructor in your form is too indented, this way it belongs to form’s Meta class, but it should be directly in CreateItemForm

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello people of StackOverflow! I have used the searrch option, I've found some related
Hi Stackoverflow people, in my current project, I have the following model structure: class
Hello again Stackoverflow people! Assume I have these words: smartphones, smartphone I want to
Hi people stackoverflow. I'm working with MVVM, I have ViewModel call UserViewModel with a
Hello people of stackoverflow. I have a problem. I'm trying to set up my
Hi Stackoverflow people, I am implementing the MarkerCluster function for google map markers. I
There are plenty of questions on stackoverflow from people who have attempted to create
Hi Stackoverflow people, I am trying to write my own contact form in Django,
Hello people from stackoverflow I have found more IE7 problems (tested in compatibility mode
Some people have mentioned (e.g. here on StackOverflow ) the tofu scale when talking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.