twoscoops / two-scoops-of-django-1.11

The issue tracker, changelog, and code repository for Two Scoops of Django 1.11
https://www.twoscoopspress.com/products/two-scoops-of-django-1-11
408 stars 68 forks source link

BASE_DIR definition #60

Closed alessandrorubio closed 7 years ago

alessandrorubio commented 7 years ago

BASE_DIR definiton

Description

Exemple 5.30 show us the following definition:

BASE_DIR = Path(__file__).resolve().parent.parent

And you suggest us to use the following folder structure with our django projects:

django_project/
       config/
        |___settings/
                 - local.py
                 - prod.py
                - etc..

With this DIRS configuration:

MEDIA_ROOT = BASE_DIR / 'media'
   STATIC_ROOT = BASE_DIR / 'static_root'
   STATICFILES_DIRS = [BASE_DIR / 'static']
   TEMPLATES = [
       {
           'BACKEND': 'django.template.backends.django.DjangoTemplates',
           'DIRS': [BASE_DIR / 'templates']
}, ]

The problem is that using BASE_DIR = Path(__file__).resolve().parent.parent we're defining BASE_DIR in django_project/config. In order to redirect BASE_DIR to the right value, I would suggest to change BASE_DIR = Path(__file__).resolve().parent.parent to BASE_DIR = Path(__file__).resolve().parent.parent.parent.

jmwoloso commented 7 years ago

+1 that's what I had to do as well for it to resolve correctly.

pydanny commented 7 years ago

🚢 🍨

@rubi0 If you give me your last name then I'll be able to include you in the acknowledgements section of the book.

alessandrorubio commented 7 years ago

Alessandro Rubio Moraes