Tagged Questions
0
votes
1answer
37 views
Postgresql performance and Django
My question is something in general as I am looking for a suggestion on the best way to work with a query on PostgreSQL with the characteristics:
Interval from client side of 5 seconds
More than ...
0
votes
2answers
17 views
Django installing custom app(Postgresql model)
I've installed following packages https://github.com/zacharyvoase/django-postgres via pip and virtualenv.:
pip install git+https://github.com/zacharyvoase/django-postgres.git
It was installed ...
0
votes
1answer
88 views
Django 1.5 : OperationalError in windows when running “python manage.py syncdb” using postgresql-psycopg2
This is my settings.py file in my Django project. OS : Windows, hosting : localhost
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': ...
0
votes
1answer
24 views
CLUSTER USING for Postgres in Django (table defragmenting / packing)
Let's say that I'm building a stack exchange clone, and every time I examine a question, I also load each and every answer. The table might look like:
id integer
question_id FOREIGN KEY
...
0
votes
1answer
32 views
Is it possible to store one specific Django model/Postgresql table on another sever?
Django natively stores all the content associated with it's models to one server. What if you wanted to store one specific Django model on another server? Is there something you can change in the ...
0
votes
1answer
66 views
What are my next debugging steps? InternalError: current transaction is aborted, commands ignored until end of transaction block
UPDATE: The problem wasn't with the previous transaction, it was happening because the database wasn't synced / migrated properly.
I've recently switched my local database to Postgres, and I'm now ...
0
votes
1answer
51 views
It's possible to delete a row in heroku postgresql?
I have a little problem here, I have a django app, that, somehow, in production DB created a row in a table that doesn't exists, with the same name as other row that does exists, ok, this might sound ...
1
vote
1answer
36 views
Getting missing column error whenever a model is saved
I'm having trouble creating a model in django. I wrote a model like this:
from django.db import models
class FooModel(models.Model):
name = models.CharField(max_length = 255)
I run
manage.py ...
0
votes
1answer
45 views
Django custom save method
I have changed the save method to include a modified date field to changed on all saves. I want to know if I update the model using update() method. Will the save method be called??
Please answer ...
0
votes
1answer
39 views
funny DatabaseError
Please can any one tell me why i get this message when saving this model below i have looked around and found people with similar problem but many solutions.
Exception Type: DatabaseError
...
0
votes
1answer
314 views
Null value in Django ORM model object's primary key
I have a Django ORM model that needs to integrate with a legacy database. The model was generated via manage.py inspectdb, and the class definition is like so:
class ClientJob(models.Model):
id = ...
0
votes
1answer
48 views
Storing lists of words in database - best practice
I'm implementing a user filter system on a website. Users are to be able to select 'categories' and 'packages' of interest to them and have the matching data presented when they log in. Both sets of ...
0
votes
1answer
83 views
Django models, how to specify foreign key on multiple columns?
So I want something similar to this:
CREATE TABLE orders(
ord_no integer PRIMARY KEY,
ord_date date,
item_code integer ,
item_name character(35),
item_grade character(1),
ord_qty numeric,
ord_amount ...
0
votes
1answer
40 views
How to log SQL requests posted by a django application?
I have a quite slow admin interface in a django application, the application is supported by apache2 and PostgreSQL.
I suspect the problem to be unoptimized sql request but I cannot understand ...
0
votes
1answer
131 views
Django find max on a join
I have two models:
class Source(models.Model):
name = models.CharField(max_length=200)
class Data(models.Model):
date = models.DateField(db_index=True)
metric = models.IntegerField()
...
2
votes
2answers
184 views
Why does Django ORM allow me to omit parameters for NOT NULL fields when creating an object?
Stupid question time. I seem to be able to create an object for a Django model even though I omit a column that was defined as NOT NULL and I don't understand why. Here's my model:
class ...
0
votes
2answers
246 views
Manage.py sqlall <myapp> does not create column
I added orgname = models.CharField(max_length=50) to my an existing class in my models.py and I ran python manage.py syncdb but figured out that it doesn't create columns (I'm using PostgreSQL by the ...
0
votes
1answer
106 views
How does postgres store django choice_fields - getting column “type” of relation does not exist error
I have a CharField type with a choices field as follows:
class Thing(models.Model):
def __unicode__(self):
return self.name
A = 'a'
B = 'b'
C = 'c'
TYPE_CHOICES = (
...
0
votes
3answers
103 views
DB design for a Course-Exam scenario with the capability of keeping track of exam types
Assume that we have a table for Course and two tables for Multiple Choice Questions(MCQ) and Normal Questions (NQ).
Each course can have several MCQs and NQs. I'm supposed to keep track of their ...
0
votes
2answers
94 views
Django - Best way to merge two identical apps
I recently came onto a project in which we have two applications that are virtually identical. We are using Django 1.4 and Postgresql 8.4. Both models have the following:
class ...
0
votes
1answer
129 views
Symbol not found: _PQbackendPID with Django project
Running on MAC os 10.6.8
with postgresSQL installed, as well django - using python2.7
Also installed psycopg2 and dj-database-url using pip in my virtual env
And added these two lines to my ...
1
vote
2answers
225 views
Django 1.4 TimeField migration fails on PostgreSQL
I edited two fields on a model and changed them from IntegerFields to TimeFields:
class Model(models.Model):
start_time = models.TimeField()
end_time = models.TimeField()
I'm using these ...
1
vote
1answer
266 views
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 ...
2
votes
2answers
416 views
Advantages to using URLField over TextField?
As I understand it you should always use a TextField for a variable length string when your using a PostgreSQL database because the speed difference between a TextField and a CharField is negligible ...
0
votes
1answer
398 views
How to access a database postgres table with a foreign key from django model
I would like simply just to access a database table, which contains a foreign key.
I have 2 tables created within postgres 9.1.
The models within Django are:
class bfirma(models.Model):
class Meta:
...
1
vote
2answers
1k views
value too long for type character varying(200) in postgres
I am using the django model for my project When I hit my query to insert the row.I am getting an error
Query:
INSERT INTO "intelligence_centre_organicsearchresults"
("keyword", "location", ...
1
vote
1answer
82 views
Relation (x > 1)-to-many
It's probably more a generic question about database, than a django one but let's go.
I have very often what could be considered as 2-to-many relations.
For example, I have a class Match in my ...
2
votes
1answer
402 views
Optimizing performance of Postgresql database writes in Django?
I've got a Django 1.1 app that needs to import data from some big json files on a daily basis. To give an idea, one of these files is over 100 Mb and has 90K entries that are imported to a Postgresql ...
0
votes
1answer
405 views
Django - Postgresql: transaction and concurrency
There is a lot of topics on Django concurrency, but after checking a lot of those, I don't feel I have found my answer when it comes to transactions.
Django version 1.3.1. Postgresql version 8.4.7.
...
1
vote
1answer
126 views
How to create multiple entries in a ManyToManyField programatically
A noob question, I'm afraid. I have a database with several classes, among them the class picture and page:
class Picture(models.Model):
picture_uuid = models.CharField(max_length=36)
class ...
2
votes
2answers
233 views
Django Database Design: ManyToManyField when using Inlines
I'm trying to design my first database and got a little bit stuck. The design is as follows: You have an author who can have many books. Each book can have many pages. Each page can have many ...
2
votes
3answers
411 views
Django Database Design: Many-to-Many, Foreign Key, or neither?
A noob question. I'm putting together my first database and have the following design problem: I have a class which defines a book (e.g. it's title) and a class which defines a page (e.g. it's ...
1
vote
2answers
351 views
Django models and PostgreSQL money type
I have an existing PostgreSQL database that I'm using for a new Django site. When I run:
python manage.py inspectdb
I get several fields which have the PostgreSQL type of "money" that do not ...
2
votes
1answer
237 views
Best way to process database in chunks with Django QuerySet?
I am running a batch operation over all rows in a database. This involves selecting every single model and doing something to it. It makes sense to split this into chunks and do it chunk by chunk.
...
3
votes
3answers
360 views
How can I improve this many-to-many Django ORM query and model set?
I have a Django query and some Python code that I'm trying to optimize because 1) it's ugly and it's not as performant as some SQL I could use to write it, and 2) because the hierarchical regrouping ...
7
votes
2answers
172 views
Simple query working for years, then suddenly very slow
I've had a query that has been running fine for about 2 years. The database table has about 50 million rows, and is growing slowly. This last week one of my queries went from returning almost ...
1
vote
1answer
155 views
Django ORM query to find all objects which don't have a recent related object
I have a repeating pattern in my code where a model has a related model (one-to-many) which tracks its history/status. This related model can have many objects representing a point-in-time snapshot ...
2
votes
1answer
275 views
Django unique_together on postgres: enforced by ORM or DB?
As I look at the sqlall for a models.py that contains unique_together statements, I don't notice anything that looks like enforcement.
In my mind, I can imagine that this knowledge might help the ...
0
votes
3answers
298 views
Using UNION in django ORM syntax between different classes in the same hierarchy
I need to implement something like
(SELECT table1.*, val=2 FROM table1 INNER JOIN table2 ON table1.id = table2.id WHERE some_condition)
UNION
(SELECT table1.*, val=3 FROM table1 INNER JOIN table3 ...
0
votes
1answer
238 views
Python PostgreSQL Transaction Error
I'm trying to use Django's ORM to do some data processing with a PostgreSQL backend. Given a primary record, generate hundreds of records in a related table, but if any errors occur, I want to ...
3
votes
2answers
294 views
GeoDjango project missing fields from database schema
I've created a Django project, using a PostGIS backend, which all seems well as far as I can tell. I've now created an app in this project as follows:
from django.contrib.gis.db import models
class ...
2
votes
3answers
1k views
Changing the Django data type in models without droping the table
I have created a Django application. Now i wanted to change the field type for 1 of my db field in models. Since there are some records already in the database with the present type, i guess its not ...
1
vote
1answer
353 views
SQL import file to update table values
How do I import an csv file to a database either SQLite or Postgresql so that it updates values already in the table and of course also inserts new ones.
Thank you...
PD: Im loving this community. ...
1
vote
3answers
207 views
Merging rows when counting - Django/SQL
I have the following model:
class Item(models.Model):
unique_code = models.CharField(max_length=100)
category_code = models.CharField(max_length=100)
label = ...
0
votes
1answer
393 views
How to separate read db server and write db server on django 0.97?
I am using Django 0.97 version with postgresql 9.0. I have configured hot streaming replication on a master db server and a slave db server. My application has heavy bot-driven writes on the DB and ...
0
votes
1answer
570 views
Safely deleting a Django model from the database using a transaction
In my Django application, I have code that deletes a single instance of a model from the database. There is a possibility that two concurrent requests could both try to delete the same model at the ...
0
votes
1answer
210 views
Model Manager filtering on Boolean causing IntegrityError
I am using a Manager on a model based on a Boolean field to filter the objects displayed on the site while showing all objects in the admin unfiltered. The idea is that user's are submitting Locations ...
10
votes
4answers
2k views
How to map PostgreSQL array field in Django ORM
I have an array field in my PostrgreSQL database of type text. Is there a way to map this into a Django model ?
4
votes
1answer
196 views
Query Limits and Order cannot work together in django
(I have a django 1.1.2 and postgresql as development environment.)
I have two queries:
tables = Table.objects.filter(is_active = True,
...
1
vote
1answer
482 views
how to create ltree data type for Django?
How to create Postgres ltree data type for Django? and how to use it with QuerySets? (create wrapper? how?)
About lree here:
http://www.postgresql.org/docs/current/static/ltree.html
About custom ...