django-settings

Setting Up Django and PostgreSQL on two different EC2 instances

╄→尐↘猪︶ㄣ 提交于 2019-11-27 21:27:15
问题 Hello StackOverFlowers :) up until now I have been running my Django back end and my PostgreSQL database on the same micro EC2 instance. I've set up two EC2 instances, one with my django back end and the other instance with my PostgreSQL database on which I use pgadminII to manage it. Both instances use the same security group and have all the same ports open. I've attached an Elastic IP to my Django instance and another Elastic IP to my Postgresql instance. Now I know in the settings.py I

ImproperlyConfigured: You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings

别来无恙 提交于 2019-11-27 17:57:50
I was trying to configure my django project to deploy to heroku. I am getting the following error and I don't really know how to fix it. Here is the full traceback and error: 22:46:15 web.1 | Traceback (most recent call last): 22:46:15 web.1 | File "/Users/nir/nirla/venv/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker 22:46:15 web.1 | worker.init_process() 22:46:15 web.1 | File "/Users/nir/nirla/venv/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106, in init_process 22:46:15 web.1 | self.wsgi = self.app.wsgi() 22:46:15 web.1 | File "/Users/nir/nirla

Why is Django throwing error “DisallowedHost at /”?

风流意气都作罢 提交于 2019-11-27 14:18:30
问题 I am setting up my own Django server using this Digital Ocean tutorial. I created the Django framework following each step, and ran the server using this command: ./manage.py runserver 0.0.0.0:8000 When I tried to visit the IP at port 8000, the following error was shown: DisallowedHost at / Invalid HTTP_HOST header: 'XXX.XXX.XXX.XXX:8000'. You may need to add u'XXX.XXX.XXX.XXX' to ALLOWED_HOSTS. (IP substituted with X's) Why is this happening? 回答1: In your settings.py , there is a list called

sqlite3.OperationalError: unable to open database file

橙三吉。 提交于 2019-11-27 12:18:24
I get this error when setting up a server in Django. It is sqlite3 which means it should create the .db file but it doesn't seem to be doing so. I've stipulated SQLite as the backend and an absolute file path for where to put it, but no luck. Is this a bug or am I doing something incorrect? (Was just thinking, is the absolute file path specified differently in Ubuntu?) Here is the beginning of my settings.py file: # Django settings for OmniCloud project. DEBUG = True TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@example.com'), ) MANAGERS = ADMINS DATABASES = { 'default': {

Simple Log to File example for django 1.3+

怎甘沉沦 提交于 2019-11-27 05:52:10
The release notes say: Django 1.3 adds framework-level support for Python’s logging module. That's nice. I'd like to take advantage of that. Unfortunately the documentation doesn't hand it all to me on a silver platter in the form of complete working example code which demonstrates how simple and valuable this is. How do I set up this funky new feature such that I can pepper my code with logging.debug('really awesome stuff dude: %s' % somevar) and see the file "/tmp/application.log" fill up with 18:31:59 Apr 21 2011 awesome stuff dude: foobar 18:32:00 Apr 21 2011 awesome stuff dude: foobar 18

ImproperlyConfigured: You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings

若如初见. 提交于 2019-11-27 03:58:52
问题 I was trying to configure my django project to deploy to heroku. I am getting the following error and I don't really know how to fix it. Here is the full traceback and error: 22:46:15 web.1 | Traceback (most recent call last): 22:46:15 web.1 | File "/Users/nir/nirla/venv/lib/python2.7/site-packages/gunicorn/arbiter.py", line 495, in spawn_worker 22:46:15 web.1 | worker.init_process() 22:46:15 web.1 | File "/Users/nir/nirla/venv/lib/python2.7/site-packages/gunicorn/workers/base.py", line 106,

How to set up a PostgreSQL database in Django

心不动则不痛 提交于 2019-11-27 02:33:44
I'm new to Python and Django. I'm configuring a Django project using a PostgreSQL database engine backend, But I'm getting errors on each database operation. For example when I run manage.py syncdb , I'm getting: C:\xampp\htdocs\djangodir>python manage.py syncdb Traceback (most recent call last): File "manage.py", line 11, in <module> execute_manager(settings) File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 438, in execute_manager utility.execute() File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 379, in execute self.fetch_command

dynamically loading django apps at runtime

老子叫甜甜 提交于 2019-11-27 01:02:59
问题 Is it possible to dynamically load django apps at runtime? Usually, apps are loaded at initialization, using the INSTALLED_APPS tuple in settings.py. However, is it possible to load additional apps at runtime? I am encountering this issue in different situations. One situation, for example, arises during testing, when I would like to dynamically load or unload apps. In order to make the problem more concrete, imagine I have a directory called apps where I put my apps and I would like to

How can I correctly set DJANGO_SETTINGS_MODULE for my Django project (I am using virtualenv)?

六眼飞鱼酱① 提交于 2019-11-27 00:27:31
问题 I am having some trouble setting the DJANGO_SETTINGS_MODULE for my Django project. I have a directory at ~/dev/django-project . In this directory I have a virtual environment which I have set up with virtualenv, and also a django project called "blossom" with an app within it called "onora". Running tree -L 3 from ~/dev/django-project/ shows me the following: . ├── Procfile ├── blossom │ ├── __init__.py │ ├── __init__.pyc │ ├── fixtures │ │ └── initial_data_test.yaml │ ├── manage.py │ ├──

How to set-up a Django project with django-storages and Amazon S3, but with different folders for static files and media files?

妖精的绣舞 提交于 2019-11-26 21:11:06
I'm configuring a Django project that were using the server filesystem for storing the apps static files ( STATIC_ROOT ) and user uploaded files ( MEDIA_ROOT ). I need now to host all that content on Amazon's S3, so I have created a bucket for this. Using django-storages with the boto storage backend, I managed to upload collected statics to the S3 bucket: MEDIA_ROOT = '/media/' STATIC_ROOT = '/static/' DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' AWS_ACCESS_KEY_ID = 'KEY_ID...' AWS_SECRET_ACCESS_KEY = 'ACCESS_KEY...' AWS_STORAGE_BUCKET_NAME = 'bucket-name' STATICFILES