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

  • Home
  • SEARCH
  • 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 6736513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:08:17+00:00 2026-05-26T11:08:17+00:00

As we know, the Django authors provide a coding style guide , to use

  • 0

As we know, the Django authors provide a coding style guide, to use as guidance when writing Django applications. However, the document provided mentions nothing specifically about forms.

Is there already a common pattern in use for this? Is the best to follow the Model style guide, with some minor adaptions? Below is how I define forms at the moment, and looking through a random selection of popular Django apps, I fail to see much consistency that agrees with my method. Can those using Django for many years now provide a recommendation?

class ExampleForm(BetterModelForm):
    # start with field definitions, as with Django Model style guide
    name = forms.CharField(label="Your Name")
    town = forms.CharField(label="Ideal city?")

    class Meta:
        # all Meta class definitions, as with Django Model style guide
        model = models.Example
        fields = ['name', 'town', 'example_field']

    def save(self):
        # ...

    def clean_name(self):
        # ...

    def clean_town(self):
        # ...

    def clean(self):
        # ...

    def custom_function(self):
        # ...

So, my style is to start with the fields, then the Meta class (with a clear line before the definition), then the save method, then any clean methods, and then any custom methods. Is this close to the standard, recommended way of doing it, if such a thing exists?

  • 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-05-26T11:08:18+00:00Added an answer on May 26, 2026 at 11:08 am

    Many of django’s model style guide lines derive from python’s pep8 guidelines, so if you haven’t done it yet have a look there! There aren’t any specific guidelines for forms, but it’s a good practice for sure to apply the rules for models to forms as well if possible (eg. order of the inner meta class).

    But probably the most important point here is to keep some consistency over your whole project, so that eg. other developers wouldn’t miss a certain method definition in long form class if they are expecting it at a certain point… But I guess everybody will agree that form classes tend to get very complex and there aren’t any official guildelines for them!

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

Sidebar

Related Questions

I know you can specify fieldsets in django for Admin helpers. However, I cannot
Somebody know how use OpenX (php app) with Django? I need to use OpenX
I'd like to know how can use Django's automatic form generation... <form action=/contact/ method=POST>
We use Django for writing our new project. Our designer wants to write templates
Does anyone know of a Django 1.0 + postgresql + apache + mod_python VMware
In Django, I know using filter with multiple arguments gets translated into SQL AND
I know you can override delete and save methods in DJango models, but can
I would like to know what is the best import strategy within django reusable
Do you know the default isolation level of the transactions used in Django? Is
I would like to know how to show an error message in the Django

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.