Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PROJECT_ROOT = os.path.dirname(__file__) error

Tags:

django

When i try:
PROJECT_ROOT = os.path.dirname(__file__)
i get error like this:
Traceback (most recent call last):
File "< stdin>", line 1, in <module>
NameError: name '__file__' is not defined

Does someone know how to fix this?

like image 724
krzyhub Avatar asked Apr 05 '11 17:04

krzyhub


1 Answers

Run that line of code via an actual module instead of in the Python REPL.

like image 117
Ignacio Vazquez-Abrams Avatar answered Sep 29 '22 09:09

Ignacio Vazquez-Abrams