[Django] #20741: Add extra context to templates of « start{app,project} » management commands

20 views
Skip to first unread message

Django

unread,
Jul 12, 2013, 6:14:37 AM7/12/13
to django-...@googlegroups.com
#20741: Add extra context to templates of « start{app,project} » management
commands
--------------------------------------------+--------------------
Reporter: palkeo | Owner: nobody
Type: New feature | Status: new
Component: Core (Management commands) | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------------+--------------------
Hi,

When creating a new app or a new project, you can generate it from a
template. It will contain files, and some files can be rendered by the
template engine.
See the docs : https://docs.djangoproject.com/en/dev/ref/django-admin
/#startapp-appname-destination

I would like to add the possibility of passing extra template context,
though command line parameters.

For example, that would allows us to pass an extra variable, « author »,
in the template context… so the generated app can correctly reference the
author.
We could also use it to choose a license…


The code that needs to be modified is here :
https://github.com/django/django/blob/master/django/core/management/templates.py#L113
I think it would be quite easy to change, and I can do a patch if you
want.

What do you think about it ?

--
Ticket URL: <https://code.djangoproject.com/ticket/20741>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jul 12, 2013, 9:41:57 AM7/12/13
to django-...@googlegroups.com
#20741: Add extra context to templates of « start{app,project} » management
commands
-------------------------------------+-------------------------------------

Reporter: palkeo | Owner: nobody
Type: New feature | Status: new
Component: Core (Management | Version: 1.5
commands) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by palkeo):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


Comment:

I have added a patch that works.

But, my help text is far from perfect.
I also didn't understood why the content of the « options » variable was
added to the context. I have removed it for now, but I don't know if that
was the right thing to do :/

--
Ticket URL: <https://code.djangoproject.com/ticket/20741#comment:1>

Django

unread,
Jul 12, 2013, 9:42:15 AM7/12/13
to django-...@googlegroups.com
#20741: Add extra context to templates of « start{app,project} » management
commands
-------------------------------------+-------------------------------------

Reporter: palkeo | Owner: nobody
Type: New feature | Status: new
Component: Core (Management | Version: 1.5
commands) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by palkeo):

* needs_better_patch: 0 => 1
* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/20741#comment:2>

Django

unread,
Sep 6, 2013, 1:54:27 PM9/6/13
to django-...@googlegroups.com
#20741: Add extra context to templates of « start{app,project} » management
commands
-------------------------------------+-------------------------------------
Reporter: palkeo | Owner: jcatalan
Type: New feature | Status: assigned

Component: Core (Management | Version: 1.5
commands) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jcatalan):

* owner: nobody => jcatalan
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/20741#comment:3>

Django

unread,
Sep 6, 2013, 2:53:30 PM9/6/13
to django-...@googlegroups.com
#20741: Add extra context to templates of « start{app,project} » management
commands
-------------------------------------+-------------------------------------
Reporter: palkeo | Owner: jcatalan
Type: New feature | Status: closed

Component: Core (Management | Version: 1.5
commands) | Resolution: wontfix

Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jcatalan):

* status: assigned => closed
* resolution: => wontfix


Comment:

Hi,

This might be nice to have, but I'm not sure if this should be supported
by the core command itself. I would probably just make my own command
subclassing TemplateCommand and adding the options your templates need.
For instance, adding the --author option.

By doing this, as it says in the
[https://docs.djangoproject.com/en/1.4/ref/django-admin/#django-admin-
option---template docs], every additional option passed will be added to
the context. So you can call it this way:
{{{#!bash
django-admin.py my_custom_startapp --template=/mytemplate <app_name>
--author=Foo
}}}

BTW, that code you erased removing options from the context it's what will
make this work, and as far as I understand from the docs I just mentioned,
it's a desired capability, so you shouldn't remove it in your patch. I'm
closing this ticket as wontfix cause I think it's better to solve this the
way I mentioned above, which doesn't modify any code in django itself.

If this doesn't solve your issue please let me know.

Juan

--
Ticket URL: <https://code.djangoproject.com/ticket/20741#comment:4>

Django

unread,
Sep 7, 2013, 7:15:42 PM9/7/13
to django-...@googlegroups.com
#20741: Add extra context to templates of « start{app,project} » management
commands
-------------------------------------+-------------------------------------
Reporter: palkeo | Owner: jcatalan
Type: New feature | Status: closed
Component: Core (Management | Version: 1.5
commands) | Resolution: wontfix
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by palkeo):

Ok, I understand.
Thanks !

--
Ticket URL: <https://code.djangoproject.com/ticket/20741#comment:5>

Django

unread,
Oct 11, 2023, 5:08:01 AM10/11/23
to django-...@googlegroups.com
#20741: Add extra context to templates of « start{app,project} » management
commands
-------------------------------------+-------------------------------------
Reporter: palkeo | Owner: jcatalan
Type: New feature | Status: closed
Component: Core (Management | Version: 1.5
commands) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed

Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak):

New [https://forum.djangoproject.com/t/startproject-command-context/24445
discussion] on the forum.

--
Ticket URL: <https://code.djangoproject.com/ticket/20741#comment:6>

Reply all
Reply to author
Forward
0 new messages