django-settings

Django ImportError: No module named middleware

核能气质少年 提交于 2019-12-10 03:52:26
问题 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__

Django - Static Files from App Directories

半腔热情 提交于 2019-12-09 17:56:30
问题 In a development environment, I'd like to use static files from the app directories. #settings.py SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) STATIC_ROOT = (os.path.join(SITE_ROOT, 'static_files/')) STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(SITE_ROOT, 'static/'), ) STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) TEMPLATE_CONTEXT_PROCESSORS = ( #... 'django.core.context

Django dynamic settings infrastructure and best practices

巧了我就是萌 提交于 2019-12-09 13:21:00
问题 Django settings includes a list of python variables that are used for a plethora of things from database settings to installed apps. Even many of the reusable apps make some of the settings required. With a dozens of sites, it is hard to manage the settings of all the projects. Fortunately settings is just a python module with variables, so you can do any magic to populate the variables you want. What practices have you followed or you think can be used to separate various related settings

Moving django apps into subfolder and url.py error

情到浓时终转凉″ 提交于 2019-12-09 09:13:42
问题 I have a question about putting django apps into "apps" subdirectory. I have the app called “faktura” in a project_root. I didn’t like the fact it lies there and I want to store all my apps under “apps” subdirectory. So, I found out that I could extend python path to “apps” subdir, so after looking in the internet, I added this string to settings.py: sys.path.insert(0, os.path.join(PROJECT_PATH, "apps")). Then I added the app to INSTALLED_APPS like “faktura”. Everything worked smooth until I

Django default_from_email name

不打扰是莪最后的温柔 提交于 2019-12-09 04:29:28
问题 I am looking to add a name to my default_from_email address in Django and wanted to know whether you do this through the settings.py file? you have your different options. DEFAULT_FROM_EMAIL EMAIL_HOST EMAIL_PASSWORD ... but the email result still ends in from: noreply@mydomain.com and I would like to change this into My Domain instead. 回答1: set DEFAULT_FROM_EMAIL = 'My Domain <noreply@mydomain.com>' 来源: https://stackoverflow.com/questions/3744680/django-default-from-email-name

AttributeError: 'module' object has no attribute 'setup'; django setup working in one project but not other

天涯浪子 提交于 2019-12-08 17:48:27
#!/usr/bin/env python # coding: utf-8 import os, sys, subprocess, time, re, ast os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webapi.server.project.settings") import django django.setup() from django.apps import apps try: cchilders: ./write_creation_tests.py Traceback (most recent call last): File "./write_creation_tests.py", line 17, in <module> django.setup() AttributeError: 'module' object has no attribute 'setup if I remove the setup attempt I can't import apps: #!/usr/bin/env python # coding: utf-8 import os, sys, subprocess, time, re, ast os.environ.setdefault("DJANGO_SETTINGS_MODULE"

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

一个人想着一个人 提交于 2019-12-07 11:54:18
问题 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. 回答1: 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',) 回答2: I think the easiest, and therefore the ans you may be looking for is to add the following

Django Debug=False whitenoise not working

浪尽此生 提交于 2019-12-07 10:18:45
问题 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

Django: No module named context_processors, Base URL

旧城冷巷雨未停 提交于 2019-12-07 07:33:50
问题 I've scoured the web for a solution but nothing seems to work. I'm getting the error: ImproperlyConfigured at /tool/page4/ Error importing module mysite.context_processors: "No module named context_processors" settings.py TEMPLATE_CONTEXT_PROCESSORS = ( # default context processors for Django 1.4 "django.contrib.auth.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors

django setting variable SECURE_PROXY_SSL_HEADER with heroku

泪湿孤枕 提交于 2019-12-07 02:01:52
问题 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