django-settings

Is it possible to change the 'migrations' folder's location outside of the Django project?

主宰稳场 提交于 2021-01-02 13:15:13
问题 what i'm trying to do is to change the default path for migrations for a specific application in a django project to put it outside the project itself but keeping it transparent, keeping use of makemigrations and migrate . Is it possible? if yes, how? 回答1: Django has a MIGRATION_MODULES setting. It allows you to specify a different module for migrations per app. The module can be outside of the Django project, it just needs to be on your python path. MIGRATION_MODULES = {'myapp': 'othermodule

Django give Error 500 for all static files like CSS and Images, when DEBUG is False

点点圈 提交于 2020-12-21 04:05:47
问题 I've tried different solutions already posted by users, but they didn't work for me. settings.py of Project BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) DEBUG = False ALLOWED_HOSTS = ["*"] STATIC_URL = '/static/' STATICFILES_DIRS=[ os.path.join(BASE_DIR,'static') ] STATIC_ROOT=os.path.join(BASE_DIR,'assets') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR,'media') All my CSS files are in style folder inside the static folder. And all images are in the media

Django give Error 500 for all static files like CSS and Images, when DEBUG is False

旧城冷巷雨未停 提交于 2020-12-21 04:05:33
问题 I've tried different solutions already posted by users, but they didn't work for me. settings.py of Project BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) DEBUG = False ALLOWED_HOSTS = ["*"] STATIC_URL = '/static/' STATICFILES_DIRS=[ os.path.join(BASE_DIR,'static') ] STATIC_ROOT=os.path.join(BASE_DIR,'assets') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR,'media') All my CSS files are in style folder inside the static folder. And all images are in the media

Django give Error 500 for all static files like CSS and Images, when DEBUG is False

痞子三分冷 提交于 2020-12-21 04:04:56
问题 I've tried different solutions already posted by users, but they didn't work for me. settings.py of Project BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) DEBUG = False ALLOWED_HOSTS = ["*"] STATIC_URL = '/static/' STATICFILES_DIRS=[ os.path.join(BASE_DIR,'static') ] STATIC_ROOT=os.path.join(BASE_DIR,'assets') MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR,'media') All my CSS files are in style folder inside the static folder. And all images are in the media

Django: input date format different when creating object from updating it

↘锁芯ラ 提交于 2020-06-27 20:01:20
问题 When I create an object and put the date into the input text field with dd/mm/yyyy format (witch is the format I want for my app) it works fine. But when I try to modify it (it means I get the key of that object and update it in the database), the input date format changes to yyyy-mm-dd (which I think is the default) and the is_valid() method never returns True. I have done a lot of thing including override the locale formats.py file, but it still doesnt work. Here is my settings.py: # Local

Change django's settings from an external source

末鹿安然 提交于 2020-05-13 14:45:26
问题 I would like to write a script in python to edit my django app settigs.py file. other than reading the file as a text file is there any other way I can edit the values of the variables in the settings file and save it? 回答1: other than reading the file as a text file is there any other way I can edit the values of the variables in the settings file and save it? There is no need to parse & rewrite settings.py as such. Just add a statement like this: import json overrides = json.loads(open(

Change django's settings from an external source

£可爱£侵袭症+ 提交于 2020-05-13 14:43:30
问题 I would like to write a script in python to edit my django app settigs.py file. other than reading the file as a text file is there any other way I can edit the values of the variables in the settings file and save it? 回答1: other than reading the file as a text file is there any other way I can edit the values of the variables in the settings file and save it? There is no need to parse & rewrite settings.py as such. Just add a statement like this: import json overrides = json.loads(open(