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
0
votes
1 answer

Could I use urlize filter in this way?

Could I use urlize filter in this way? : from django.utils.html import urlize def save(self, force_insert=False, force_update=False): self.body = urlize(self.body) super(Post, self).save(force_insert, force_update) body is a TextField.
xRobot
  • 25,579
  • 69
  • 184
  • 304
0
votes
1 answer

IntegrityError with Booleand Fields and Postgresql

I have this simple Blog model: class Blog(models.Model): title = models.CharField(_('title'), max_length=60, blank=True, null=True) body = models.TextField(_('body')) user = models.ForeignKey(User) is_public =…
xRobot
  • 25,579
  • 69
  • 184
  • 304
0
votes
1 answer

Listing database objects efficiently

I'm working on a page that lists companies and their employees. Employees have sales. These are saved in a database. Now I need to list all of them. My problem is that the current solution is not fast. One page load takes over 15 seconds. Currently…
MikkoP
  • 4,864
  • 16
  • 58
  • 106
0
votes
2 answers

Why doesn't django.db.models.Avg() return a datetime object? And why is what it returns wrong?

Here is my Django model: class MyModel(models.Model): a = IntegerField() b = DateTimeField() Here is the QuerySet I execute on this model to find the count, min, max and average bs for each value of a: >>>…
Saqib Ali
  • 11,931
  • 41
  • 133
  • 272
0
votes
1 answer

Django database optimization: Should I filter and count in python or use Django's queryset.count()

I have a few views in Django where I query the database about 50 times. I am wondering if it is faster to query the database or to grab the items once and count myself in python. For example: On one page, I want to list the following statistics: -…
0
votes
1 answer

How to filter between two databases?

I have two databases: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'new', 'USER': 'xxxxx', 'PASSWORD': 'xxxxx', 'HOST': '', 'PORT': '', }, …
Nips
  • 13,162
  • 23
  • 65
  • 103
0
votes
1 answer

django tries to read from wrong DB table

Here is my settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'mydbname', 'USER': 'username', 'PASSWORD': 'password', 'HOST': '#IP Address that your DB is hosted on' …
ghostrider
  • 5,131
  • 14
  • 72
  • 120
0
votes
0 answers

Where is PostgreSQL database file stored? (Django Project)

I am working on a Django project and have started to used Postgres (as opposed to sqlite3), however, I am unsure where the database file is stored. I am on a Mac OS X Mavericks, and am starting my server using Postgress.app. I also have pgAdmin3…
ng150716
  • 2,195
  • 5
  • 40
  • 61
0
votes
1 answer

Rename a table used as reference in a another table

I have created two PostgreSQL tables tables (the code originates from a Django app): CREATE TABLE "app_book" ( "id" serial NOT NULL PRIMARY KEY, "title" varchar(256) ); CREATE TABLE "app_author" ( "book_ptr_id" integer NOT NULL PRIMARY…
mimo
  • 2,469
  • 2
  • 28
  • 49
0
votes
1 answer

django database api to use where value in <> clause for strings

Using django need to return a query set where values should be IN variable p1 and p2 : p1 = 's' p2 = 't' formset_OK=pocketTransactionFormset(queryset=Pockets.objects.filter(pocket_owner=request.user).extra(where=['pocket_name=%s'],…
paarth batra
  • 1,392
  • 4
  • 29
  • 53
0
votes
1 answer

PostgreSQL sequence being reset?

On a regular occasion, my Django webapps produce SQL errors on M2M tables. Each time it turns out the ID sequence is reset to a value within the range of existing rows. The app performs normal SQL queries such as: INSERT INTO "myapp_project"…
vdboor
  • 21,914
  • 12
  • 83
  • 96
0
votes
0 answers

Django Database settings

I've two databases in my Django app, BUT with different IP's, ie HOST are different. 'default': { # This is the DB in the same machine itself. 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'sortation_gor', …
Praful Bagai
  • 16,684
  • 50
  • 136
  • 267
0
votes
2 answers

Django Database Module

I am developing a system that will need to connect from a remote mysql database on the fly to do a specific task. To accomplish this, I am thinking to use Mysql-db module in python. Since the remote database is not part of the system itself I do not…
helloworld2013
  • 3,094
  • 5
  • 19
  • 26
0
votes
1 answer

Django: Sort database import by the last entry first and so on

I am using the following to import the database entries and it works fine by listing contents from first entry to the last on the database: users_temp = users.objects.all() --> where users is a table in my database. How do I change the above…
summerNight
  • 1,446
  • 3
  • 25
  • 52
0
votes
0 answers

One django Instance with different databases per model

Can I have a Django Instance of a project(one setting file) but different database per model or model instance? What do I mean. Suppose we have a model Business class Business(models.Model): #buisness specific fields A model Employer class…
Apostolos
  • 7,763
  • 17
  • 80
  • 150