A R
A R

Reputation: 510

How do I get the absolute path from the settings file in Django

I have a simple question:

I have read a lot of answers in this forum on how to get a project's root directory. However I'm running into a problem: the path is just .

For example:

from django.conf import settings

path = settings.BASE_DIR + /somefolder/

the resulting value for path is just .

I need the full path in order to save to that folder.

Upvotes: 1

Views: 3289

Answers (1)

ettanany
ettanany

Reputation: 19806

Use the following:

import os
from django.conf import settings

folder_path = os.path.join(settings.BASE_DIR, 'somefolder')

Upvotes: 3

Related Questions