Questions tagged [django-database]

django-database refers to database backends that Django supports out of the box

refers to database backends that Django supports out of the box.

This tutorial help you to make application using mongodb database. enter link description here

664 questions
10
votes
3 answers

Difference between auto_now_add and timezone.now as default value

What is the difference between auto_now_add and timezone.now (as default value) for models in Django? Example: create_date = models.DateTimeField(auto_now_add=True) and create_date = models.DateTimeField(default=timezone.now) ? UPD. I'm talking…
wowkin2
  • 5,895
  • 5
  • 23
  • 66
10
votes
3 answers

Connecting to AWS Postgres Instance For Django Backend

I've created a PostgreSQL database on AWS, which I want to use for a Django project. I've modified settings.py so that it has DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql', 'NAME': , …
Batman
  • 8,571
  • 7
  • 41
  • 80
10
votes
1 answer

Django - Runtime database switching

In my work we want to run a server with multiple databases. The databases switching should occur when you acces a url like http://myapp.webpage.com or http://other.webpage.com. We want to run only one server instance and at the moment of the HTTP…
10
votes
1 answer

django - loaddata error when converting db from sqlite3 to postgres

I am trying to convert from a sqlite3 db to Postgres (so that I can have timezone-aware datetime fields with django 1.4). I dumped the data from the sqlite3 db. Then switched settings to point to the empty postgres db. Then ran syncdb, then south…
mb52089
  • 872
  • 2
  • 10
  • 24
9
votes
4 answers

CommandError: You appear not to have the 'psql' program installed or on your path

I'm using Windows, no virtualenv. I have psycopg2 installed with Pip, and the latest version of PostgreSQL installed as well. When I run ./ manage.py dbshell, I get the following error: CommandError: You appear not to have the 'psql' program…
Valachio
  • 1,025
  • 2
  • 18
  • 40
9
votes
2 answers

dynamically set database based on request in django

I am writing a multi-tenant application with python-django. I want to set database connection based on each request.I thought i could write a middleware where we set the database to be used for that particular database. import re from django.db…
Vijay Shanker
  • 417
  • 4
  • 10
8
votes
2 answers

How to implement django admin on an existing database where you have read-only access?

I want to use Django admin to browse and existing database but I want to be sure that me or Django are not going to do any modifications to this database. For this reason I think I should use two database, one that is the read-only one and one that…
sorin
  • 161,544
  • 178
  • 535
  • 806
8
votes
3 answers

How to add database routers to a Django project

I'm following the instructions on how to handle multiple databases within one Django project from here topics/db/multi-db I've created the two routers required. They are saved as ./database_routers/discourse.py and…
Keith John Hutchison
  • 4,955
  • 11
  • 46
  • 64
8
votes
3 answers

How do I test a method in Django which closes the database connection?

I have a long running Python process which uses the Django ORM. It looks something like this: import django from django.db import connection from my_app import models def my_process(): django.setup() while (True): do_stuff() …
Rahul Gupta-Iwasaki
  • 1,683
  • 2
  • 21
  • 39
8
votes
2 answers

ForeignKey to a Model field?

I want a foreign key relation in my model with the username field in the User table(that stores the user created with django.contrib.auth.forms.UserCreationForm). This how my model looks: class Blog(models.Model): username =…
8
votes
4 answers

Migrating database from local development to Heroku-Django 1.8

After establishing a database using heroku addons:create heroku-postgresql:hobby-dev, I tried to migrate my local database to heroku database. So I first ran heroku python manage.py migrate. After that I created a dump file of my local database…
WutWut
  • 1,204
  • 2
  • 17
  • 31
8
votes
1 answer

Django 1.6 and nesting "with transaction.atomic()"

I've got used through the years to the older transaction.commit_on_success and transaction.commit_manually with Django < 1.6. But now with Django 1.6 the old API is replaced mainly with transaction.atomic. After reading the docs on the new API, I'm…
Loic Duros
  • 5,472
  • 10
  • 43
  • 56
8
votes
4 answers

git merge conflicts with our database file (multiple developers)

A buddy and I are developing a Django app and are using git. As we work, we make fake accounts on our site, login, and upload content to the database, etc..for testing purposes. Every time we merge branches, we get merge conflicts in our database…
sgarza62
  • 5,998
  • 8
  • 49
  • 69
8
votes
1 answer

Django DynamoDB Database backend

Is it possible to set up an AWS DynamoDB as the database backed for a Django server? If so, how would I go about doing this? thanks!
7
votes
5 answers

Django Testing: no data in temporary database file

I'm using a sqlite3 database set up as follows in settings.py: DATABASES = { 'default': { 'ENGINE': 'django.contrib.gis.db.backends.spatialite', 'NAME': 'path/to/config.sqlite', 'TEST_NAME': 'path/to/test-config.sqlite', …
Constantinius
  • 34,183
  • 8
  • 77
  • 85
1 2
3
44 45