django-settings

Django: Run a script right after runserver

萝らか妹 提交于 2021-02-19 03:37:08
问题 Context: I have a table on the database that uses values from an external database. This external database updates its values periodically. Problem: In order to update my database everytime i start the server, I want to run a script right after the runserver. Potential Solution: I have seen that it is possible to run a script from a certain app, which is something I'm interested in. This is achievable by using the django-extensions : https://django-extensions.readthedocs.io/en/latest

Django Whitenoise 500 server error in non debug mode

倾然丶 夕夏残阳落幕 提交于 2021-02-19 03:28:10
问题 I am using django in my local machine. In order to serve the static files I used WhiteNoise along with it. When DEBUG = True all static files are correctly served. But when I changed DEBUG = False and set ALLOWED_HOSTS = ['*'] I'm getting 500 server error. However admin site loads without any error. Also when I comment out STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' I don't get 500 error. I followed the documentation given in http://whitenoise.evans.io/en

Hiding settings.py passwords for Heroku Django deployment

眉间皱痕 提交于 2021-02-18 07:51:41
问题 I have sensitive data (database passwords) in settings.py and I was advised to upload my Django project to a github repository before pushing it to Heroku on their "Getting Started with Django on Heroku". If I put settings.py in .gitignore, then presumably it won't get deployed with my project. How can I prevent settings.py from being exposed but still get it deployed with my project ? 回答1: You can use environment variables (with heroku config:add SECRET=my-secret ) to setup sensitive data

How to run static file when debug is false? [closed]

感情迁移 提交于 2021-02-13 17:41:16
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 days ago . Improve this question With debug turned off Django won't handle static files for you any more - your production web server. Implement this code inside your project: settings.py STATIC_DIR=os.path.join(BASE_DIR,'static') STATIC_URL = '/static/' if DEBUG: STATICFILES_DIRS = [ STATIC_DIR,

How to run static file when debug is false? [closed]

有些话、适合烂在心里 提交于 2021-02-13 17:39:27
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 3 days ago . Improve this question With debug turned off Django won't handle static files for you any more - your production web server. Implement this code inside your project: settings.py STATIC_DIR=os.path.join(BASE_DIR,'static') STATIC_URL = '/static/' if DEBUG: STATICFILES_DIRS = [ STATIC_DIR,

Django: INSTALLED_APPS is “.apps.AppConfig” redundant?

烈酒焚心 提交于 2021-02-11 18:14:36
问题 I didn't see an answered version of this question, and this has really been bothering me because I've seen both be used. In this example "myapp" is the created app. I keep seeing users setup their apps inside of the INSTALLED_APPS list like this: INSTALLED_APPS = [ 'myapp', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] instead of INSTALLED_APPS = [ 'myapp.apps.MyappConfig',

CommandError: You appear not to have the 'psql' program installed or on your path

对着背影说爱祢 提交于 2021-02-07 20:45:24
问题 I'm using Windows, no virtualenv. I have psycopg2 installed with Pip, and the latest version of PostgreSQL installed as well. When I run ./ manage.py dbshell , I get the following error: CommandError: You appear not to have the 'psql' program installed or on your path. When I run ./ manage.py dbshell psql , I get this: usage: manage.py dbshell [-h] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--database DATABASE] manage.py dbshell:

CommandError: You appear not to have the 'psql' program installed or on your path

浪子不回头ぞ 提交于 2021-02-07 20:43:25
问题 I'm using Windows, no virtualenv. I have psycopg2 installed with Pip, and the latest version of PostgreSQL installed as well. When I run ./ manage.py dbshell , I get the following error: CommandError: You appear not to have the 'psql' program installed or on your path. When I run ./ manage.py dbshell psql , I get this: usage: manage.py dbshell [-h] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--database DATABASE] manage.py dbshell:

Django development server keeps logging out

和自甴很熟 提交于 2021-01-28 10:20:04
问题 I set my SESSION_COOKIE_AGE settings to 360 in my settings.py,, but the it keeps logging me out while I am developing my server :(( Why is this happening and how do I prevent this..? Thanks! Here is my settings.py: settings.py # Django settings for quora project. import os.path DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( ('myname', 'myemail'), ) MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3'

Django development server keeps logging out

老子叫甜甜 提交于 2021-01-28 10:11:11
问题 I set my SESSION_COOKIE_AGE settings to 360 in my settings.py,, but the it keeps logging me out while I am developing my server :(( Why is this happening and how do I prevent this..? Thanks! Here is my settings.py: settings.py # Django settings for quora project. import os.path DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( ('myname', 'myemail'), ) MANAGERS = ADMINS DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3'