I've read the previous threads on this topic and tried to modify the code, but no success again.
The problem is that I get IOError message at %s. No such file or directory
error in the following view:
def some_view(request):
MYDIR = os.path.dirname(__file__)
with open(os.path.join(MYDIR, '/static/egais_files/client.xml'), 'w') as f:
# ....
client.xml
is located in the following folder:
\10.8.0.1sharedjprjdjprjstaticstaticegais_filesclient.xml
Any ideas what am I doing wrong ?
UPDATE 1:
The .py file containing some_view
is located in \10.8.0.1sharedjprjdjprjdjprjegaisviews.py
UPDATE 2. The settings.py file
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUG = True
ROOT_URLCONF = 'supermarket_project.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(os.path.dirname(BASE_DIR),"static","templates")],
#'DIRS': [os.path.join(BASE_DIR,"templates")],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],},},]
WSGI_APPLICATION = 'supermarket_project.wsgi.application'
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
STATIC_URL = '/static/'
if DEBUG:
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR),"static","static-only")
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR),"static","media")
STATICFILES_DIRS = (os.path.join(os.path.dirname(BASE_DIR),"static","static"),
)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…