django-settings

Django: Allow admin user to edit site-wide settings?

≯℡__Kan透↙ 提交于 2019-12-25 06:52:43
问题 I have a Django site, and I'd like to allow a couple of site-wide settings: ADMIN_EMAIL - email address for an administrative user REMINDER_TEXT - email text for an email that the site will generate once a week to be edited in the admin interface. What is the most sensible way to do this? Should I store these values in settings.py , or somewhere in the database? This previous SO question seems to be related, but I don't think it's ever been fully answered. Thanks! 回答1: Ideally, settings.py

Accessing Django Templates after modifing the Django layout structure

不羁的心 提交于 2019-12-24 18:55:39
问题 I re-organized Django,the following way: config - settings - base.py - local.py urls.py wsgi.py also apps: - apps(level0) - acc(level_1) - users(level_2) - templates - users - acc_control(level_2) -att(level_1) - notes (level_2) - notifications (level_2) - mark(level_1) - config (level0) - templates(level0) Some apps are directly in apps folder, ex mark, others are in other subfolders, ex users BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) TEMPLATES =

Django cant find templates

╄→гoц情女王★ 提交于 2019-12-24 10:02:01
问题 So ive been trying to setup a django settings module that will check the environment variable and load settings. Heres what my settings module looks like /templates home.html /settings base.py prod.py dev.py test.py base.py PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)) TEMPLATE_DIRS = [ os.path.join(PROJECT_ROOT, "templates"), ] urls.py from django.views.generic.simple import direct_to_template urlpatterns = patterns('', url(r"^$", direct_to_template, {'template' : 'home.html' },

django - can't see the uploaded media files from apache

一世执手 提交于 2019-12-24 00:49:40
问题 I have two different directory for both media and static. And as I upload the files through the local server (localhost:8000), I can see the uploaded images both by the local server and the apache server. However, when I upload it with apache(localhost), I can't see them. I can only see the static. But when I reload the page served by the local server (not runserver again), I can then see those pictures both by the local server and the apache. What am I doing wrong? Any help will be

Django settings: raise KeyError, raise ImproperlyConfigured or use defaults?

不羁岁月 提交于 2019-12-24 00:20:53
问题 Django expects you to use environment variables in settings.py to adapt to multiple environments (e.g. local, heroku, AWS). I guess I should define -for instance- the username of the DB in an environment variable DB_USERNAME . How should I read it? import os DB_USERNAME = os.environ['DB_USERNAME'] DB_USERNAME = os.environ.get('DB_USERNAME') DB_USERNAME = os.environ.get('DB_USERNAME', 'john') Should I capture the KeyError and raise a ImproperlyConfigured myself? I prefer to make the app stop

After upgrade to Django 1.11 append_slash no longer works

痴心易碎 提交于 2019-12-24 00:12:26
问题 In Django 1.9 (and Python 3.4) the default of APPEND_SLASH worked correctly, i.e. I could enter 'localhost:8000/ideatree/videos' and the trailing slash would be added. After an upgrade to Django 1.11 (and Python 3.6), APPEND_SLASH is no longer working. I've looked for deprecation notices but so far found nothing that seems to apply. (side question: how do you turn 'loud deprecation warnings' back on, as they were in previous versions?) Here is my main urls.py: from django.conf.urls import

(DatabaseError: no such table: django_session) ERROR during Django 1.3 selenium testing

萝らか妹 提交于 2019-12-23 23:14:57
问题 I'm trying to use django selenium for testing my django1.3 application. The database backend for the testing is sqlite3. Here is a snippet of my settings file. if 'test' in sys.argv: DB_ENGINE = 'django.db.backends.sqlite3' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'TEST_NAME': ':memory:', 'NAME': 'database_one', }, 'database_two': { 'ENGINE': 'django.db.backends.sqlite3', ] 'TEST_NAME': ':memory:', 'NAME': 'database_two', }, 'database_three': { 'ENGINE': 'django.db

No such table as django_site

我的未来我决定 提交于 2019-12-23 16:42:50
问题 I am following from the docs of django-disqus to use it in my project. I have installed it in my settings, with other needed settings ( API key and short name ). But when I try to run these commands: >>> from django.contrib.sites.models import Site >>> Site.objects.all() I am getting an error: OperationalError: no such table: django_site I have already installed django.contrib.admin in my settings and is using it in my project. So what am I missing? 回答1: Make sure you have added 'django

404 on media files - Django

你。 提交于 2019-12-23 14:57:49
问题 Last night I uploaded my project to pythonanywhere.com where I wanted to test my production settings. In one of my models I allow users to upload JPG's (Logo of a team). The uploading process works good, the file lands in my MEDIA_ROOT. The issue is that when I try to access it in my template (to display it on the page) I get a 404. My first thought is that my MEDIA_URL is not configured properly but I still don't know why. I want to say that my media folder isn't in the project - it is

No module named sql_server.pyodbc.base

你。 提交于 2019-12-23 11:37:54
问题 I wanted to use SQL Server as the backend for Django, but I got this when debugging the web project. 'sql_server.pyodbc' isn't an available database backend. Error was: No module named sql_server.pyodbc.base. Python Environments (Python 2.7) with Django (1.7), pyodbc(3.0.10), pywin32(218.3). And here is my settings.py: DATABASES = { 'default': { 'ENGINE': 'sql_server.pyodbc', 'NAME': 'DatabaseName', 'USER': 'user', 'PASSWORD': 'pwd', 'HOST': '127.0.0.1', 'PORT': '', 'OPTIONS': { 'driver':