以下为:nginx的配置。
server {
listen 80;
root /home/django-sites/Trovato;
server_name trovato.schoolmedia.cn;
#host and port to fastcgi server
location / {
fastcgi_pass 127.0.0.1:8080;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param pass_header Authorization;
fastcgi_intercept_errors off;
}
location /static {
root /home/django-sites/Trovato/;
break;
}
location /media {
root /home/django-sites/Trovato/;
break;
}
#设置浏览器缓存这些图片格式文件浏览器缓存时间是30天,css/js缓存时间1小时
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
-****我是华丽的分界线***
以下为:django项目配置:
ROOT_URLCONF = 'Trovato.urls'
WSGI_APPLICATION = 'Trovato.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'trovato',
'HOST': '127.0.0.1',
'PORT': '3306',
'USER': 'root',
'PASSWORD': 'yeyatou.sql',
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
TEMPLATE_DIRS = [ os.path.join(BASE_DIR, 'templates'), ]
STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'public'), ]
****************分界线
问题是:django项目的首页出项,可setting文件丝毫不起作用.....
【我明明配置的是mysql数据库】
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in login
359. return login(request, **defaults)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
76. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
105. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/views.py" in login
37. if form.is_valid():
File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in is_valid
162. return self.is_bound and not bool(self.errors)
File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in errors
154. self.full_clean()
File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in full_clean
354. self._clean_form()
File "/usr/local/lib/python2.7/dist-packages/django/forms/forms.py" in _clean_form
378. cleaned_data = self.clean()
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/forms.py" in clean
192. password=password)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/__init__.py" in authenticate
59. user = backend.authenticate(**credentials)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/backends.py" in authenticate
16. user = UserModel._default_manager.get_by_natural_key(username)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/models.py" in get_by_natural_key
159. return self.get(**{self.model.USERNAME_FIELD: username})
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py" in manager_method
92. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in get
351. num = len(clone)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in __len__
122. self._fetch_all()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in _fetch_all
966. self._result_cache = list(self.iterator())
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in iterator
265. for row in compiler.results_iter():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in results_iter
700. for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in execute_sql
784. cursor = self.connection.cursor()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py" in cursor
165. cursor = self.make_debug_cursor(self._cursor())
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py" in _cursor
138. self.ensure_connection()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py" in ensure_connection
133. self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py" in __exit__
94. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py" in ensure_connection
133. self.connect()
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/__init__.py" in connect
122. self.connection = self.get_new_connection(conn_params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py" in get_new_connection
374. conn = Database.connect(**conn_params)
Exception Type: OperationalError at /admin/login/
Exception Value: unable to open database file
【怎么办!!!!】