[Django] #23575: Templates override with Admin Site TEMPLATE_DIRS better method possibly

92 views
Skip to first unread message

Django

unread,
Sep 30, 2014, 12:26:25 PM9/30/14
to django-...@googlegroups.com
#23575: Templates override with Admin Site TEMPLATE_DIRS better method possibly
---------------------------------+---------------------------
Reporter: hernandocounty | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.7
Severity: Normal | Keywords: TEMPLATES_DIR
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+---------------------------
the current way listed did not work for me.

It would behoove the beautiful documentation of Django to make it a little
more clear.

http://stackoverflow.com/questions/4938491/django-admin-change-header-
django-administration-text

here is the link.

I would be delighted to help in this project.

thanks

Doug


Is there anything else I could do to help ?

If you tell me what info you need and don't treat me like I'm an idiot I
would love to help.

Sorry Just had a lot of negative experiences trying to contribute to
projects.

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

Django

unread,
Sep 30, 2014, 12:31:46 PM9/30/14
to django-...@googlegroups.com
#23575: Templates override with Admin Site TEMPLATE_DIRS better method possibly
---------------------------------+--------------------------------------

Reporter: hernandocounty | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.7
Severity: Normal | Resolution:

Keywords: TEMPLATES_DIR | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

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


Comment:

You can read about
[https://docs.djangoproject.com/en/1.7/internals/contributing/writing-
documentation/ contributing to our documentation]. From your report, it's
not clear where the error is in our docs.

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

Django

unread,
Sep 30, 2014, 12:50:07 PM9/30/14
to django-...@googlegroups.com
#23575: Templates override with Admin Site TEMPLATE_DIRS better method possibly
---------------------------------+--------------------------------------

Reporter: hernandocounty | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.7
Severity: Normal | Resolution:

Keywords: TEMPLATES_DIR | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by hernandocounty):

Customizing your project’s templates

Create a templates directory in your project directory. Templates can live
anywhere on your filesystem that Django can access. (Django runs as
whatever user your server runs.) However, keeping your templates within
the project is a good convention to follow.

Open your settings file (mysite/settings.py, remember) and add a
TEMPLATE_DIRS setting:
mysite/settings.py

TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]

TEMPLATE_DIRS is an iterable of filesystem directories to check when
loading Django templates; it’s a search path.

Now create a directory called admin inside templates, and copy the
template admin/base_site.html from within the default Django admin
template directory in the source code of Django itself
(django/contrib/admin/templates) into that directory.

this is what I tried along with these solutions also.

i tried these solutions from earlier versions

# TEMPLATE_DIRS = [os.path.join(BASE_DIR,
'/home/<username>/dev/09292014/stocks_day1/templates/')]

TEMPLATE_DIRS = ('/home/<username>/dev/09292014/stocks_day1/templates',)

these i placed in settings.py after trying the method in the tutorial.

Thanks

Doug

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

Django

unread,
Sep 30, 2014, 1:00:55 PM9/30/14
to django-...@googlegroups.com
#23575: Templates override with Admin Site TEMPLATE_DIRS better method possibly
---------------------------------+--------------------------------------

Reporter: hernandocounty | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.7
Severity: Normal | Resolution:

Keywords: TEMPLATES_DIR | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by timgraham):

Are you using the version of the tutorial that matches the version of
Django you have installed? It's not clear to me what the problem is
besides things "not working." Did you find your error? Without knowing
that, I'm not sure how things should be clarified. See
[https://docs.djangoproject.com/en/dev/#getting-help Getting Help] if you
need to help resolving the problem, as we try to avoid using this ticket
tracker as a support channel.

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

Django

unread,
Sep 30, 2014, 1:06:17 PM9/30/14
to django-...@googlegroups.com
#23575: Templates override with Admin Site TEMPLATE_DIRS better method possibly
---------------------------------+--------------------------------------

Reporter: hernandocounty | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.7
Severity: Normal | Resolution:

Keywords: TEMPLATES_DIR | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by hernandocounty):

Im not looking for support. I have the problem fixed by the method on
the link I sent you by editing the urls.py instead of the settings.py and
the TEMPLATE_DIRS method.

You guys are way ahead of guys like me. You guys understand this stuff in
a different way . You wrote it Probably. But myself, I have a background
in Physics and am about Jr Level Django guy.

I am honeslty trying to help the documentation, Not looking for Support.

Editing the urls.py solution is much faster and makes more sense to guys
at my level IMHO.

the guy on the stack overflow even said in 1.7 things are different with
TEMPLATES_DIRS and its only necessary to edit urls.py to achieve the
result of changing the title of the admin site.

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

Django

unread,
Sep 30, 2014, 1:07:32 PM9/30/14
to django-...@googlegroups.com
#23575: Templates override with Admin Site TEMPLATE_DIRS better method possibly
---------------------------------+--------------------------------------

Reporter: hernandocounty | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.7
Severity: Normal | Resolution:

Keywords: TEMPLATES_DIR | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by hernandocounty):

I followed the tutorial as best as a guy with a physics degree can. If it
confuses me, It probably confuses a lot of other people too.

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

Django

unread,
Sep 30, 2014, 1:13:18 PM9/30/14
to django-...@googlegroups.com
#23575: Templates override with Admin Site TEMPLATE_DIRS better method possibly
---------------------------------+--------------------------------------

Reporter: hernandocounty | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.7
Severity: Normal | Resolution:

Keywords: TEMPLATES_DIR | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by hernandocounty):

yes I am using the 1.7 tutorial.

I tried the other methods when the 1.7 version did not work.

There was no error message.. It was just that the Site Admin Text did not
change unless I edited urls.py, which took all of 3 seconds as opposed to
the 24 hours of trying the method on the tutorial.

Im not trying to be a dick man.. just trying to help and I know other
people have had this problem.

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

Django

unread,
Sep 30, 2014, 1:15:28 PM9/30/14
to django-...@googlegroups.com
#23575: Templates override with Admin Site TEMPLATE_DIRS better method possibly
---------------------------------+--------------------------------------

Reporter: hernandocounty | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.7
Severity: Normal | Resolution:

Keywords: TEMPLATES_DIR | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by timgraham):

Oh now I understand your suggestion. Well, we don't use that method for
the reason described in the tutorial, "We use this approach to teach you
how to override templates. In an actual project, you would probably use
the django.contrib.admin.AdminSite.site_header attribute to more easily
make this particular customization." So I am not sure what we should do.
Suggestions?

--
Ticket URL: <https://code.djangoproject.com/ticket/23575#comment:7>

Django

unread,
Sep 30, 2014, 1:29:06 PM9/30/14
to django-...@googlegroups.com
#23575: Templates override with Admin Site TEMPLATE_DIRS better method possibly
---------------------------------+--------------------------------------

Reporter: hernandocounty | Owner: nobody
Type: New feature | Status: new
Component: Template system | Version: 1.7
Severity: Normal | Resolution:

Keywords: TEMPLATES_DIR | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+--------------------------------------

Comment (by hernandocounty):

Awesome. Wow man thanks for listening. Really Cool . Ok . Could we just
make another section and just call it Alternative method to do this ?
something simple. I really do feel like it fits the DRY principle . As for
what is in the Tutorial. Is there something I missed that makes it
difficult to execute ? I seriously spent quite a bit of time on it and
would even be willing to start it over from scratch and screenshot it all
. Maybe I would find a common mistake / pitfall that occurs for newbs like
me ?

--
Ticket URL: <https://code.djangoproject.com/ticket/23575#comment:8>

Django

unread,
Sep 30, 2014, 1:58:29 PM9/30/14
to django-...@googlegroups.com
#23575: Add a code example for custom AdminSite
--------------------------------------+------------------------------------
Reporter: hernandocounty | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: TEMPLATES_DIR | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* component: Template system => Documentation
* type: New feature => Cleanup/optimization
* easy: 0 => 1
* stage: Unreviewed => Accepted


Comment:

I probably wouldn't include the alternative in the tutorial itself since
`site_header` is already linked to the admin docs. The instructions are on
that page:
"If you’d like to set up your own administrative site with custom
behavior, however, you’re free to subclass AdminSite and override or add
anything you like. Then, simply create an instance of your AdminSite
subclass (the same way you’d instantiate any other Python class), and
register your models and ModelAdmin subclasses with it instead of using
the default."

but a code example would be helpful.

I'd guess maybe you didn't setup the directory structure quite right in
order for template overriding to work. It should be
`mysite/templates/admin` and not `mysite/mysite/templates/admin`.

--
Ticket URL: <https://code.djangoproject.com/ticket/23575#comment:9>

Django

unread,
Sep 30, 2014, 2:10:55 PM9/30/14
to django-...@googlegroups.com
#23575: Add a code example for custom AdminSite
--------------------------------------+------------------------------------
Reporter: hernandocounty | Owner: nobody

Type: Cleanup/optimization | Status: new
Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: TEMPLATES_DIR | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by hernandocounty):

Yes but even that method is too much. Like I said, The guy on stack
overflow had the simplest solution of just editing urls.py

and yes I did have the templates directory in the right place.

I am seriously confused as to why it did not work. Everything you suggest
I have tried.

I think the only solution is for me to start it over in a new VM and
document my process. Until then we wont have the same data to work with .

--
Ticket URL: <https://code.djangoproject.com/ticket/23575#comment:10>

Django

unread,
Oct 30, 2014, 7:58:20 AM10/30/14
to django-...@googlegroups.com
#23575: Add a code example for custom AdminSite
-------------------------------------+-------------------------------------
Reporter: hernandocounty | Owner:
Type: | berkerpeksag
Cleanup/optimization | Status: assigned

Component: Documentation | Version: 1.7
Severity: Normal | Resolution:
Keywords: TEMPLATES_DIR | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by berkerpeksag):

* owner: nobody => berkerpeksag
* status: new => assigned
* has_patch: 0 => 1


Comment:

https://github.com/django/django/pull/3444

--
Ticket URL: <https://code.djangoproject.com/ticket/23575#comment:11>

Django

unread,
Oct 30, 2014, 8:46:59 AM10/30/14
to django-...@googlegroups.com
#23575: Add a code example for custom AdminSite
-------------------------------------+-------------------------------------
Reporter: hernandocounty | Owner:
Type: | berkerpeksag
Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.7
Severity: Normal | Resolution: fixed

Keywords: TEMPLATES_DIR | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"4a9b4a23bdb51c9fce06facaf78c9ba0a54f1266"]:
{{{
#!CommitTicketReference repository=""
revision="4a9b4a23bdb51c9fce06facaf78c9ba0a54f1266"
Fixed #23575 -- Added a code example for custom AdminSite.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23575#comment:12>

Django

unread,
Oct 30, 2014, 8:52:47 AM10/30/14
to django-...@googlegroups.com
#23575: Add a code example for custom AdminSite
-------------------------------------+-------------------------------------
Reporter: hernandocounty | Owner:
Type: | berkerpeksag
Cleanup/optimization | Status: closed
Component: Documentation | Version: 1.7
Severity: Normal | Resolution: fixed
Keywords: TEMPLATES_DIR | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"cb952099f4aeac263501c185441872af06927606"]:
{{{
#!CommitTicketReference repository=""
revision="cb952099f4aeac263501c185441872af06927606"
[1.7.x] Fixed #23575 -- Added a code example for custom AdminSite.

Backport of 4a9b4a23bd from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/23575#comment:13>

Reply all
Reply to author
Forward
0 new messages