passing additional context variables to project template

106 views
Skip to first unread message

Dominique Guardiola Falco

unread,
May 5, 2012, 8:55:12 AM5/5/12
to django-d...@googlegroups.com
Sorry to cross-post this, as I just posted it on django-users,
but it's perhaps a little problem with the django documentation here

I have a working project template that I can use with the new "--template" option of the startproject management command
I wanted to pass more variables in the template_context, and the doc [1] says  :

The template context used is:
  • Any option passed to the startproject command
  • project_name -- the project name as passed to the command
  • project_directory -- the full path of the newly created project
  • secret_key -- a random key for the SECRET_KEY setting
But when I type for example  :
django-admin.py startproject --template=/home/admin/tmpl/ --myvar="hey" mynewprojectname
I get : django-admin.py: error: no such option: --myvar

TemplateCommand(BaseCommand) uses optparse, and from what I read on this module, it's normal that optparse refuses options that were not defined before ?
Am I missing a specific syntax to use here or does the documentation is wrong ?

Thanks for your help


[1] https://docs.djangoproject.com/en/1.4/ref/django-admin/#django-admin-startproject

Dominique Guardiola
http://www.quinode.fr/

hirokiky

unread,
May 5, 2012, 10:43:18 PM5/5/12
to Django developers
Hi, Dominique.

It's right that you have said.
One bring up the topic on <http://groups.google.com/group/django-
developers/browse_thread/thread/d1a24c319ed48c79/8763643df0166097?
lnk=gst&q=startproject#8763643df0166097>.

Quotation:
> I found the docs a little misleading when they say 'Any option passed to the startapp command' will be added to the context.
> This got me thinking I could add arbitrary options to the command and pass them in to the context, which would make for some
> highly configurable app/project boilerplates. But, from looking at the source I gather by 'any options' they meant any valid options for the startapp/project commands.

I think the discussion will help you.

---------------------------------------------
hirokiky: Hiroki KIYOHARA.
http://hirokiky.org/
Reply all
Reply to author
Forward
0 new messages