django-settings

Configuring Django

故事扮演 提交于 2019-12-21 03:59:07
问题 I just installed Django 1.6 on OS X 10.8 with python 2.7 and am having trouble going through the tutorial. After setting creating a server called mysite by running: django-admin.py startproject mysite I then cd'ed into mysite and ran python manage.py runserver and got this error: Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from

Configuring Django

被刻印的时光 ゝ 提交于 2019-12-21 03:59:06
问题 I just installed Django 1.6 on OS X 10.8 with python 2.7 and am having trouble going through the tutorial. After setting creating a server called mysite by running: django-admin.py startproject mysite I then cd'ed into mysite and ran python manage.py runserver and got this error: Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from

Django - template context processors - breaking my app

瘦欲@ 提交于 2019-12-21 03:32:09
问题 I was trying to set up a template context processor like this article mentions so that I could provide information to every template. I wrote this function in views.py: def items_in_cart(request): """Used by settings.TEMPLATE_CONTEXT_PROCESSORS to provide an item count to every template""" cart, lines = get_users_cart_and_lines(request) return {'items_in_cart': lines.count()} And then I added this line to settings.py: TEMPLATE_CONTEXT_PROCESSORS = ('Store.views.items_in_cart',) But now

Django AUTHENTICATION_BACKENDS import error

限于喜欢 提交于 2019-12-20 19:47:29
问题 What is the proper way to import a custom backend in settings.py? I currently have the following in settings.py: AUTHENTICATION_BACKENDS = ('apps.apployment_site.auth.CustomAuth') where apployment_site is the app, auth is file name, and CustomAuth is the class name. In my view, I get: ImportError: a doesn't look like a module path after I run the following code: from django.contrib.auth import authenticate from apployment_site import * authenticate(username="username", password="password")

django settings per application - best practice?

二次信任 提交于 2019-12-20 11:01:25
问题 this is somewhat related to this question Why is django's settings object a LazyObject? In my django project i have several applications. Each application can have its own non-trivial settings file. proj/ proj/ settings.py app/ settings.py views.py What is the general best practice here? should app/settings.py do from django.conf import settings APP_SETTING= lambda: settings.getattr('APP_SETTING', 'custom_value') PROJ_SETTING= lambda: settings.PROJ_SETTING and then in app/views.py do import

What's the difference between `from django.conf import settings` and `import settings` in a Django project

我们两清 提交于 2019-12-20 09:08:14
问题 I'm reading up that most people do from django.conf import settings but I don't undertstand the difference to simply doing import settings in a django project file. Can anyone explain the difference? 回答1: import settings will import the first python module named settings.py found in sys.path , usually (in default django setups). It allows access only to your site defined settings file, which overwrites django default settings ( django.conf.global_settings ). So, if you try to access a valid

How do you fix the following Django Error: “Type: IOError” “Value: [Errno 13] Permission denied”

孤人 提交于 2019-12-19 09:55:10
问题 I am following a Django Tutorial where you are required to construct some image thumbnails once an image is saved in admin. I am also using Python's tempfile module to save a temporary file name. However I keep running into the following error: "Type: IOError" "Value: [Errno 13] Permission denied: 'c:\\docume~1\\myname\\locals~1\\temp\\somefilename'" Here is the code I am using Settings MEDIA_ROOT = '/home/myname/projectname/media/' MEDIA_URL = 'http://127.0.0.1:8000/media/'enter code here

How to define a default value for a custom Django setting

房东的猫 提交于 2019-12-18 12:07:42
问题 The Django documentation mentions that you can add your own settings to django.conf.settings . So if my project's settings.py defines APPLES = 1 I can access that with settings.APPLES in my apps in that project. But if my settings.py doesn't define that value, accessing settings.APPLES obviously won't work. Is there some way to define a default value for APPLES that is used if there is no explicit setting in settings.py ? I'd like best to define the default value in the module/package that

Django: “No module named context_processors” error after reboot

非 Y 不嫁゛ 提交于 2019-12-18 03:49:32
问题 I have a Django site that works on my PC, and was working briefly on my server after loading it on. I noticed my server had Django 1.6 and I upgraded to 1.8. After rebooting, none of the pages on my site load and I get the error: ImportError No module named context_processors I read through the docs on Django and allauth. Django mentions that in 1.8 the context_processors moved and allauth says specific allauth tags are no longer needed in the TEMPLATE_CONTEXT_PROCESSORS of settings.py .

sqlite3.OperationalError: unable to open database file

末鹿安然 提交于 2019-12-17 09:31:26
问题 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