define BASE_DIR?

2,560 views
Skip to first unread message

Christopher Spears

unread,
May 21, 2013, 5:08:06 PM5/21/13
to django...@googlegroups.com
I am working my way through the Django tutorial, and I have reached the part where I am supposed to customize the look and feel of the admin.  I am supposed to do that using the mysite\settings.py file (working on a Windows laptop).  I have two questions.

At first, I just typed the following into the file:

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

I got an error message stating that os.path was not recognized.  I solved this by putting 'import os.path' at the top of the file.  Does this mean there is a bug in the tutorial's documentation?  I do not recall seeing any instructions that told me to add this.

After I solved the first problem, I now get this error message:

  File "C:\Users\Chris\Documents\django_dev\mysite\mysite\settings.py", line 7,
in <module>
    TEMPLATE_DIRS = [os.path.join(BASE_DIR, 'templates')]
NameError: name 'BASE_DIR' is not defined

Am I supposed to now define BASE_DIR?

Thanks!

Charly Román

unread,
May 21, 2013, 5:12:11 PM5/21/13
to django...@googlegroups.com
2013/5/21 Christopher Spears <cspea...@yahoo.com>:
You need to define BASE_DIR, for example:

BASE_DIR = os.path.dirname(os.path.realpath(__file__))

Tom Evans

unread,
May 22, 2013, 8:06:18 AM5/22/13
to django...@googlegroups.com
BASE_DIR is only mentioned in the tutorial from the in development
docs, which may not be the best place to start - chiefly because it
can have issues like this.

If you don't mind encountering things like this, then using the dev
docs helps find issues like this that have been added since the last
release, but if you want a more checked and correct django docs, use
the ones from the latest release.

Of course, you should always use the docs for the version that you are
actually using. I would recommend not using unreleased versions of
django to learn django though.

Cheers

Tom

StefanoC

unread,
Oct 8, 2013, 6:44:16 AM10/8/13
to django...@googlegroups.com, teva...@googlemail.com
Hello!

as much as I understand / agree the point of not using the dev version/doc especially for newbies, I found this https://code.djangoproject.com/ticket/20400 ticket about it that was closed as invalid.

Shouldn't this be open and valid instead? Otherwise this doc bug would never get fixed (in addition it's a worthy addition to the settings as best practice in my opinion)?

Stefano
Reply all
Reply to author
Forward
0 new messages