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 8833647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:49:50+00:00 2026-06-14T08:49:50+00:00

I’ve been running into crispy form , and it seems to do exactly what

  • 0

I’ve been running into crispy form, and it seems to do exactly what I want: render forms with bootstrap layout.

Now, the example talk about using forms.Form. This is ok, I can create mine by writing the code like this:

class TemplateCreateForm(forms.Form):
    title = forms.CharField(label=(u'Task name'))
    description = forms.CharField(label=(u'Task description'))
    url_start = forms.CharField(label=(u'Start page url'))
    url_end = forms.CharField(label=(u'Final page url'))

    def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_method = 'post'
        self.helper.add_input(Submit('submit', 'Submit'))
        super(TemplateCreateForm, self).__init__(*args, **kwargs)

But, how to do the update? because if I put this in the view:

    form = TemplateCreateForm(request.POST or None, instance=template)

it does not work because instance is only for ModelForm.

Now, can I substitute the forms.Form with ModelForm and use crispy form for ModelForm?
I did this

class TemplateCreateForm(ModelForm):
    title = forms.CharField(label=(u'Task name'))
    description = forms.CharField(label=(u'Task description'))
    url_start = forms.CharField(label=(u'Start page url'))
    url_end = forms.CharField(label=(u'Final page url'))

    def __init__(self, *args, **kwargs):
        self.helper = FormHelper()
        self.helper.form_method = 'post'
        self.helper.add_input(Submit('submit', 'Submit'))
        super(TemplateCreateForm, self).__init__(*args, **kwargs)

    class Meta:
        model = Template
        exclude = ('user')

Here I added the Meta class.
Now: it works, but is it correct to use it like this?
The update works as well in this way.

What’s the correct way to use forms for doing the update?

  • 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-14T08:49:51+00:00Added an answer on June 14, 2026 at 8:49 am

    I’m the lead developer of django-crispy-forms. I’m not sure I follow your question as it’s a bit poorly formatted. What exactly are you trying to do?

    django-crispy-forms does work with ModelForms, the same way as with simple forms. It sits on top of Django, so it doesn’t mess with it. It only controls your form rendering, but doesn’t change how validation works, how to create form instances and so on.

    EDIT:

    I’m adding an example on how to do a ModelForm with crispy-forms.

    class ExampleModelForm(forms.ModelForm):
        def __init__(self, *args, **kwargs):
            super(ExampleModelForm, self).__init__(*args, **kwargs)
    
            # If you pass FormHelper constructor a form instance
            # It builds a default layout with all its fields
            self.helper = FormHelper(self)
    
            # You can dynamically adjust your layout
            self.helper.layout.append(Submit('save', 'save'))
    
        class Meta:
            model = ExampleModel
    

    I believe your first problem is that you were subclassing forms.Form instead of forms.ModelForm. That’s why I said that your problem was Django related, not crispy-forms related.

    Later in your view:

    form = ExampleModelForm()
    

    In your template:

    {% load crispy_forms_tags %}
    {% crispy form %}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I want use html5's new tag to play a wav file (currently only supported
I am trying to render a haml file in a javascript response like so:

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.