django-settings

Django: Session Cache not updated when using Cookie Based Session Storage

梦想的初衷 提交于 2019-12-04 18:53:16
I am trying to use Django Session to cache some data. I don't have a database in my web app so, I am using the cookie-based storage mechanism. I am able to successfully save the data in the session only for the first time. Henceforth, if I try to update the session cache it doesn't work. Here is what I had found: prior_states = request.session.get(workflow_id, []) print "prior_state >>> ", prior_states if state_id in prior_states: request.session.update({workflow_id: prior_states[:prior_states.index(state_id) + 1]}) else: prior_states.append(state_id) request.session.update({workflow_id :

django logging - django.request logger and extra context

梦想与她 提交于 2019-12-04 18:07:41
问题 Am on django 1.3., python 2.6 In the django docs here https://docs.djangoproject.com/en/1.3/topics/logging/#django-request it says that messages have the following extra context: status and request. How do you get these to show up in the debug file? i tried in my logging config something like: 'formatters': { 'simple_debug': { 'format': '[%(asctime)s] %(levelname)s %(module)s %(message)s %(request.user)s', } }, but that causes the overall logging to fail (i.e. no logging output happens) EDIT:

Bizarre error importing settings in django

依然范特西╮ 提交于 2019-12-04 12:10:56
问题 I have many projects working in ubuntu with python2.7 and virtualenv/virtualenvwrapper, in my work some developers works with macosx and windows, generally I create the project as usual: django-admin.py start project x And we use svn for cvs, but in some point, without nothing rational for me, when I try something like: python manage.py runserver doesn't work, but is just for me and is in my laptop, that doesn't happens in productions servers or another developers. any ideas? I got this error

Why do we have to provide WSGI_APPLICATION variable in Django settings

十年热恋 提交于 2019-12-04 10:09:26
I'm a beginner Django developer so if this question doesn't make sense please forgive me. We provide a variable called WSGI_APPLICATION in django settings along with ROOT_URLCONF and some other settings variables. and we provide settings file path in wsgi.py file as well, import os import django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGSS_MODULE", "<settings_file_path>") application = get_wsgi_application() So you see, its a two way connection.right? I mean path of settings file in wsgi file and path of wsgi file in settings file. so why do we have to do this.

Python/Django - Avoid saving passwords in source code

时光总嘲笑我的痴心妄想 提交于 2019-12-04 07:29:20
问题 I use Python and Django to create web applications, which we store in source control. The way Django is normally set up, the passwords are in plain text within the settings.py file. Storing my password in plain text would open me up to a number of security problems, particularly because this is an open source project and my source code would be version controlled (through git, on Github, for the entire world to see!) The question is, what would be the best practice for securely writing a

Django - Static Files from App Directories

给你一囗甜甜゛ 提交于 2019-12-04 06:56:09
In a development environment, I'd like to use static files from the app directories. #settings.py SITE_ROOT = os.path.dirname(os.path.realpath(__file__)) STATIC_ROOT = (os.path.join(SITE_ROOT, 'static_files/')) STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(SITE_ROOT, 'static/'), ) STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) TEMPLATE_CONTEXT_PROCESSORS = ( #... 'django.core.context_processors.static', #... ) INSTALLED_APPS = ( #... 'django.contrib.staticfiles', #... ) I can find my static

STATIC_URL Not Working After Django 1.5 Upgrade

寵の児 提交于 2019-12-04 05:14:53
问题 Im probably just tired and dont notice something obvious here but after upgrade to Django 1.5 the path to my static files is broken. settings.py from os.path import abspath, basename, dirname, join, normpath SITE_ROOT = dirname(dirname(abspath(__file__))) SITE_NAME = basename(SITE_ROOT) PROJECT_ROOT = dirname(SITE_ROOT) STATIC_ROOT = normpath(join(SITE_ROOT, 'static', 'site_media')) STATIC_URL = "/site_media/static/" STATICFILES_FINDERS = ( "staticfiles.finders.FileSystemFinder", "staticfiles

Using external URLs in Django's TEMPLATE_DIRS

非 Y 不嫁゛ 提交于 2019-12-03 19:13:40
问题 Django's TEMPLATE_DIRS in Settings.py calls for unix style slashes. Because of this, when I call get_template('some/template.html') in a view, the result always starts at the root, and results in a call to /home/username/projectname/public/some/template.html The problem is that I'd like to use templates hosted on an entirely different site. This works fine for other Settings.py fields (MEDIA_URL and STATIC_URL), where it will take an absolute http path with no objection. Given an http path,

Django AUTHENTICATION_BACKENDS import error

一个人想着一个人 提交于 2019-12-03 12:28:54
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") Here's my full settings.py: """Django settings for apployment project. For more information on this file,

Configuring Django

末鹿安然 提交于 2019-12-03 11:57:01
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_command_line utility.execute() File "/Library/Python/2.7/site-packages/django/core/management/__init__.py"