django-settings

sqlite3.OperationalError: unable to open database file

我怕爱的太早我们不能终老 提交于 2019-12-17 09:31:04
问题 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

Simple Log to File example for django 1.3+

六眼飞鱼酱① 提交于 2019-12-17 07:59:51
问题 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

Django - after login, redirect user to his custom page --> mysite.com/username

有些话、适合烂在心里 提交于 2019-12-17 04:20:14
问题 By default after login django redirects the user to an accounts/profile page or if you edit the LOGIN_REDIRECT_URL you can send the user to another page you specify in the settings.py. This is great but I would like the user (after login) to be redirected to a custom page where the link to that page would look something like this: mysite.com/username . So the default accounts/profile or the LOGIN_REDIRECT_URL settings would not work in this case since both are somehow static. In my case the

STATICFILES on Django 1.6.2

回眸只為那壹抹淺笑 提交于 2019-12-13 07:19:53
问题 This is my settings.py STATIC_URL = '/static/' TEMPLATE_DIRS = ( os.path.join(BASE_DIR, 'templates'), ) STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), ) STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) My structure is: manage.py myproject -- __init__.py -- settings.py -- urls.py -- wsgi.py -- static ----- css ----- img -------- logo.png

Django and OpenShift static files can't be found

梦想与她 提交于 2019-12-13 04:59:37
问题 So I followed this tutorial: https://github.com/rancavil/django-openshift-quickstart/wiki/Tutorial-How-create-an-application-with-Django-1.6-on-Openshift and I tried to add a static image to the default home.html page and it just won't find it. HTML: {% load static %} <html> <head> </head> <body> <img src="{% static 'Logo_Trans.png' %}"> <div class="left"></div> <div class="right"> <p>is coming soon</p> </div> </body> </html> All other files are as listed in the repo given. 回答1: I've found

After installing jinja2 TemplateDoesNotExist at /admin/

狂风中的少年 提交于 2019-12-12 17:01:19
问题 I have installed jinja2 and after that 'DIRS' stopped working(I have to include them by hand). Changing 'APP_DIRS' doesn`t help templates look like that: TEMPLATES = [ { 'BACKEND': 'django.template.backends.jinja2.Jinja2', 'APP_DIRS': False, 'DIRS': ['main/templates', 'shop/templates'], 'OPTIONS': { 'environment': 'django_test.create_jinjia_env.environment', 'autoescape': True, 'auto_reload': DEBUG, 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context

Django Testing - I only want one of my databases created - how to specify

久未见 提交于 2019-12-12 14:43:08
问题 So in my settings.py I specified two database connections (see below). But when I run tests I only want Django to create the 'default' database. Is there any way to do this? I tried adding the TEST_CREATE: False option but I guess that's only for Oracle for some reason? My settings.py snippet: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 'NAME': 'App1', # Or path to database file if using sqlite3.

Python: 'import *' vs execfile

时光怂恿深爱的人放手 提交于 2019-12-12 07:47:08
问题 In some of my Django apps I'm using a settings_local.py file to override settings that are different on various environments (e.g. development, test and production). I have originally used the following code to include its contents in the settings.py : try: from settings_local import * except ImportError: sys.stderr.write("The settings_local.py file is missing.\n") DEBUG=False I have recently found the execfile function and switched to something like: try: execfile(path.join(PROJECT_ROOT,

No module named 'allauth.account.context_processors'

可紊 提交于 2019-12-12 07:14:43
问题 I want to use Django-Allauth, so I installed as following and it works perfectly in my laptop localhost; but when I pull it in my server, I encounter with the following error: No module named 'allauth.account.context_processors' What should I do? # Django AllAuth TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'templates')], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ # Already defined Django-related contexts here #

while use .env got NameError: name 'config' is not defined

百般思念 提交于 2019-12-12 01:16:17
问题 I'm following a tutorial to upload static file to amazon S3 to. I need to add two things in the settings.py AWS_ACCESS_KEY_ID = config'AWS_ACCESS_KEY_ID' AWS_SECRET_ACCESS_KEY = config'AWS_SECRET_ACCESS_KEY' For safety reasons I create a file named .env its form is .text directly through pycharm. After I added these code in the settings.py.I restarted nginx and gunicorn and then I activated virtual environment and run python manage.py collectstatic Then I got the error NameError: name 'config