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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:29:41+00:00 2026-06-13T18:29:41+00:00

In my django app I am writing a custom management command which will create

  • 0

In my django app I am writing a custom management command which will create an instance of an object based on the args passed and have the option of saving it to the database based on whether an option --save is passed or not.

I’ve got a lot of help on this from the django documentation itself. Have also got important pointers from here about how to pass multiple arguments and here about how to have options.

from optparse import make_option

class Command(BaseCommand):
  option_list = BaseCommand.option_list + (
    make_option('--delete',
        action='store_true',
        dest='delete',
        default=False,
        help='Delete poll instead of closing it'),
    )

  def handle(self, *args, **options):
    # ...
    if options['delete']:
        poll.delete()
    # ...

However I am not able to find a detailed explanation of the fields in make_option. For example optparse.make_option lists

Instance attributes:
_short_opts : [string]
_long_opts : [string]

action : string
type : string
dest : string
default : any
nargs : int
const : any
choices : [string]
callback : function
callback_args : (any*)
callback_kwargs : { string : any }
help : string
metavar : string

In this help is self explanatory and I figured out what dest would mean, but I’m not clear what action='store_true' means. In fact it’d be great if someone could give me a short description of what all the arguments to make_option mean…

Thanks a lot

  • 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-13T18:29:43+00:00Added an answer on June 13, 2026 at 6:29 pm

    The optparse docs might be a little bit more helpful. You are basically telling the management function what each option you require should do.

    The action keyword is the most telling and it configures what you want to do with that option – is it just a flag to do something special (a callback, i.e. ‘–enable-feature’) or should it accept a parameter for example (store, i.e. ‘-things 10’).

    With that in mind, the rest of the options make a bit more sense with that all in mind. Read through ‘option attributes’ to get an explanation of what you’ve listed, and then ‘actions’ to see what I’ve mentioned above

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

Sidebar

Related Questions

I'm writing my first Django app and want to create a header model which
In my django app, I have a view which accomplishes file upload.The core snippet
Following the example of writing a custom django-admin command here , I've created the
I'm writing a simple real-estate listing app in Django. Each property needs to have
I'm writing a Python-based shell script to boilerplate a Django app with virtualenv, pip,
I am writing forum app on Django using custom session/auth/users/acl system. One of goals
I'm writing a Django App, where I am expecting to use many management.py commands.
I am writing an app in Django which has a few sitewide fixed objects
I am writing Django app, it is an admin interface based on jQuery Grid
I have been writing some a django project / app that initiates some test

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.