[Django] #20400: during tutorial02 os, BASE_DIR not defined

23 views
Skip to first unread message

Django

unread,
May 12, 2013, 7:49:48 PM5/12/13
to django-...@googlegroups.com
#20400: during tutorial02 os, BASE_DIR not defined
--------------------------------+--------------------
Reporter: karim.nassar@… | Owner: nobody
Type: Uncategorized | Status: new
Component: Documentation | Version: 1.5
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+--------------------
If you follow the instructions in the tutorial02:
https://docs.djangoproject.com/en/dev/intro/tutorial02/#customizing-your-
project-s-templates

You get error:
{{{
File "/home/myUser/path/to/project/projectName/projectName/settings.py",
line 116, in <module>
os.path.join(BASE_DIR, 'templates')
NameError: name 'os' is not defined
}}}
You need to add this line:
{{{
import os
}}}
Then you get this error:
{{{
File "/home/myUser/path/to/project/projectName/projectName/settings.py",
line 116, in <module>
os.path.join(BASE_DIR, 'templates')
NameError: name 'BASE_DIR' is not defined
}}}
Add this line to settings.py:
{{{
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
}}}
Maybe that needs to be in tutorial?

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

Django

unread,
May 12, 2013, 9:01:16 PM5/12/13
to django-...@googlegroups.com
#20400: during tutorial02 os, BASE_DIR not defined
--------------------------------+--------------------------------------
Reporter: karim.nassar@… | Owner: nobody
Type: Uncategorized | Status: closed
Component: Documentation | Version: 1.5
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* status: new => closed
* needs_docs: => 0
* resolution: => invalid
* needs_tests: => 0
* needs_better_patch: => 0


Comment:

You are likely using the development version of the tutorial (notice "dev"
in the url) with Django 1.5 instead of the development version of Django.

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

Django

unread,
May 22, 2013, 11:53:25 AM5/22/13
to django-...@googlegroups.com
#20400: during tutorial02 os, BASE_DIR not defined
--------------------------------+--------------------------------------
Reporter: karim.nassar@… | Owner: nobody
Type: Uncategorized | Status: closed
Component: Documentation | Version: 1.5
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by anonymous):

This really should be in the tutorial.

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

Django

unread,
Aug 25, 2013, 1:08:31 PM8/25/13
to django-...@googlegroups.com
#20400: during tutorial02 os, BASE_DIR not defined
--------------------------------+--------------------------------------
Reporter: karim.nassar@… | Owner: nobody
Type: Uncategorized | Status: closed
Component: Documentation | Version: 1.5
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by anonymous):

Thanks a lot!

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

Django

unread,
Nov 8, 2013, 4:42:55 PM11/8/13
to django-...@googlegroups.com
#20400: during tutorial02 os, BASE_DIR not defined
--------------------------------+--------------------------------------
Reporter: karim.nassar@… | Owner: nobody
Type: Uncategorized | Status: closed
Component: Documentation | Version: 1.5
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by rando305@…):

I recently had this same problem. It would be nice to update this
Tutorial. However - I am very pleased with the Tutorial and Django. I'm
looking forward to writing code again.

After doing this - I still get an error __file__ is not defined. Any help
would be appreciated.

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

Django

unread,
Nov 8, 2013, 5:48:05 PM11/8/13
to django-...@googlegroups.com
#20400: during tutorial02 os, BASE_DIR not defined
--------------------------------+--------------------------------------
Reporter: karim.nassar@… | Owner: nobody
Type: Uncategorized | Status: closed
Component: Documentation | Version: 1.5
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by timo):

As noted above, if you have this problem, you aren't using the correct
version of the tutorial for the version of Django you have installed.

Please see
[https://code.djangoproject.com/wiki/TicketClosingReasons/UseSupportChannels
SupportChannels] for getting help. This ticket tracker is not the place to
get help.

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

Django

unread,
Apr 30, 2014, 5:17:36 PM4/30/14
to django-...@googlegroups.com
#20400: during tutorial02 os, BASE_DIR not defined
--------------------------------+--------------------------------------
Reporter: karim.nassar@… | Owner: nobody
Type: Uncategorized | Status: closed
Component: Documentation | Version: 1.6
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

* version: 1.5 => 1.6


Comment:

I'm using v1.6 and the following url:
http://django.readthedocs.org/en/1.6.x/intro/tutorial02.html

I'm not using "dev" and the "import os" and setting BASE_DIR is still not
explained.

Love the docs, but things like this detract from the lessons that the
tutorial is actually trying to teach.

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

Django

unread,
May 16, 2014, 6:37:11 AM5/16/14
to django-...@googlegroups.com
#20400: during tutorial02 os, BASE_DIR not defined
--------------------------------+--------------------------------------
Reporter: karim.nassar@… | Owner: nobody

Type: Uncategorized | Status: closed
Component: Documentation | Version: 1.6
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

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

Comment (by erikr):

Replying to [comment:6 ShawnMTherrien]:


> I'm not using "dev" and the "import os" and setting BASE_DIR is still
not explained.

Yes, this is true. However, this will not lead to the error you describe.
The context of this in the tutorial is that you add the lines to the
settings file. In Django 1.6, the standard settings
[[https://github.com/django/django/blob/stable/1.6.x/django/conf/project_template/project_name/settings.py|already
import os and define BASE_DIR]].

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

Reply all
Reply to author
Forward
0 new messages