django-settings

Django - Using a different email backend for admin error emails

醉酒当歌 提交于 2019-12-07 01:46:50
问题 I'm using a custom email backend in my Django application (CeleryEmailBackend in this case): EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend' My logging configuration: LOGGING = { # ... 'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler', }, # ... } The Admin error emails also get sent by the same email backend. So if there is a problem with the email backend (e.g. Celery is not running). Then I won't

Django can't find staticfiles with Debug=False and Allowed_Hosts

最后都变了- 提交于 2019-12-06 22:29:06
问题 Hi all I'm having trouble solving this issue: If I turn DEBUG to False, I can't run manage.py runserver: CommandError: You must set settings.ALLOWED_HOSTS if DEBUG is False Then, let's say I add something to ALLOWED_HOSTS: ALLOWED_HOSTS = ['*'] or ALLOWED_HOSTS = ['localhost'] or ALLOWED_HOSTS = ['127.0.0.1', 'localhost'] Now, I can do ´manage.py runserver´ but the staticfiles don't work. Weird. If I turn DEBUG to True, then it works with ALLOWED_HOSTS set to nothing, to localhost or to *. So

Django: Session Cache not updated when using Cookie Based Session Storage

最后都变了- 提交于 2019-12-06 12:38:39
问题 I am trying to use Django Session to cache some data. I don't have a database in my web app so, I am using the cookie-based storage mechanism. I am able to successfully save the data in the session only for the first time. Henceforth, if I try to update the session cache it doesn't work. Here is what I had found: prior_states = request.session.get(workflow_id, []) print "prior_state >>> ", prior_states if state_id in prior_states: request.session.update({workflow_id: prior_states[:prior

How can I print the value of TEMPLATE_DIRS from the django interactive shell?

与世无争的帅哥 提交于 2019-12-06 03:48:00
I would like to print this value for debugging purposes. How can I do it? print TEMPLATE_DIRS doesn't work print settings.TEMPLATE_DIRS doesn't work. Did you import the settings first? $steve ./manage.py shell Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05) In [1]: from django.conf import settings In [2]: settings.TEMPLATE_DIRS Out [2] ('/Volumes/HDD/usr/local/django/mytestproject/templates',) I think the easiest, and therefore the ans you may be looking for is to add the following to your settings.py print ("This is the template.dirs", TEMPLATES[0]['DIRS'])...python 3.x for 2.x leave out the

Why do we have to provide WSGI_APPLICATION variable in Django settings

北战南征 提交于 2019-12-06 03:25:09
问题 I'm a beginner Django developer so if this question doesn't make sense please forgive me. We provide a variable called WSGI_APPLICATION in django settings along with ROOT_URLCONF and some other settings variables. and we provide settings file path in wsgi.py file as well, import os import django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGSS_MODULE", "<settings_file_path>") application = get_wsgi_application() So you see, its a two way connection.right? I mean

Django findstatic : No matching file found

♀尐吖头ヾ 提交于 2019-12-05 20:15:43
A while ago, I attempted to use "collectstatic" in Django to serve my static files and failed miserably. Now I am finally trying to get my static files serving correctly in my development environment. I can't figure out what has gone wrong. When I run python manage.py findstatic images/add.png console returns: base path: C:\Projects\AlmondKing\AlmondKing static files dirs: C:\Projects\AlmondKing\AlmondKing\static No matching file found for 'images/add.png'. The directory paths are correct, but it still can't locate my files. I've tried a number of different settings configurations to no avail.

Django Debug=False whitenoise not working

余生长醉 提交于 2019-12-05 17:36:23
I am trying to deploy my fully functional (when local and Debug=True) site to Heroku. When I use the default Django staticfile_storage settings, my site appears live but without any static files (css, images, etc). The admin panel works but it doesn't have any styles either. But, when I try to use Whitenoise, which is what I originally intended, I get a server 500 error. The admin panel will not work then. I can't figure out for the life of me what I am doing wrong. I have tried to model my settings.py file after Heroku's template: https://github.com/heroku/heroku-django-template , and

django setting variable SECURE_PROXY_SSL_HEADER with heroku

放肆的年华 提交于 2019-12-05 08:15:13
I am trying to set variables related to https/ssl on django 1.8 with heroku. but in Django 1.8 tutorial, it saids that i should be careful setting this variable expecially "SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')" In django 1.8 tutorial it saids Warning You will probably open security holes in your site if you set this without knowing what you’re doing. And if you fail to set it when you should. Seriously. Make sure ALL of the following are true before setting this (assuming the values from the example above): Your Django app is behind a proxy. Your proxy strips the X

Django ImportError: No module named middleware

我们两清 提交于 2019-12-05 05:36:14
I am using Django version 1.8 and python 2.7. I am getting the following error after running my project. Traceback (most recent call last): File "C:\Python27\lib\wsgiref\handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "C:\Python27\lib\site-packages\django\contrib\staticfiles\handlers.py", line 63, in __call__ return self.application(environ, start_response) File "C:\Python27\lib\site-packages\django\core\handlers\wsgi.py", line 170, in __call__ self.load_middleware() File "C:\Python27\lib\site-packages\django\core\handlers\base.py", line 50, in

Django - Using a different email backend for admin error emails

最后都变了- 提交于 2019-12-05 04:46:02
I'm using a custom email backend in my Django application (CeleryEmailBackend in this case): EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend' My logging configuration: LOGGING = { # ... 'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler', }, # ... } The Admin error emails also get sent by the same email backend. So if there is a problem with the email backend (e.g. Celery is not running). Then I won't receive the server error emails. Is there a way to make AdminEmailHandler use a custom email backend? It