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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:28:20+00:00 2026-06-01T03:28:20+00:00

I am currently using CreateView for the class Order . Part of the urls.py

  • 0

I am currently using CreateView for the class Order.

Part of the urls.py looks like this

url(
    r'^orders/create/$',
    CreateView.as_view(
        model = Order,
        template_name = 'doors/orders/create.html'
    ),
    name = 'orders_create'
),

If I simply do a {{ form }} inside a oors/orders/create.html, then it will display all the fields declared in models.py.

What is the best way to customize the look of each field and to even control whether they are even visible or not (some of the fields are optional)?

  • 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-01T03:28:22+00:00Added an answer on June 1, 2026 at 3:28 am

    To answer the part of your question concerning which fields of the model should be available in the form, you could create a custom form with ModelForm. The options fields and exclude define which fields are available in the form:

    https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form

    You would then tell the CreateView to use your custom form by adding form_class:

    url(
        r'^orders/create/$',
        CreateView.as_view(
            model = Order,
            template_name = 'doors/orders/create.html',
            form_class = OrderCreateForm,
        ),
        name = 'orders_create'
    ),
    

    Concerning the second part of your question (how to style the form and its fields), you could use {{ form.as_p }}, {{ form.as_table }} or put together a completely custom template:

    https://docs.djangoproject.com/en/dev/topics/forms/#displaying-a-form-using-a-template

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

Sidebar

Related Questions

Currently I am using a Html.EditorFor control in a default 'Create' View page like
I currently only have the create view for my Album class: @model MvcApplication1.Models.AlbumViewModel @{
Currently using the HTTPServletRequest class and specifically the .getQueryString method to retrieve an inputted
I'm currently using DPack as this adds a Collapse All Projects option to the
I have this model: public class ExchangeRate { [Key] public int ExchangeRateID { get;
Im currently using a plugin called Cycle for jQuery and would like to tweak
Im currently using a UITableView like any other, and I am researching into the
Im currently using CodeIgniters active record class to UPDATE a MySQL table. One of
I'm trying to make updates to a model using Ajax/POST. I'd like to be
Currently using MySQL version 5.1.6 This is my first real world build and 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.