Use this tag for PostgreSQL issues which are to be solved in accordance with Django coding best practices.
Questions tagged [django-postgresql]
207 questions
0
votes
0 answers
Django Automated Testing doesn't work with heroku postgresql database
I made a Django app from the tutorial using a postgresql database. The automated testing worked fine when my app was running locally. I have since deployed it to heroku and when I try to run the tests I get this error:
RuntimeWarning: Normally…

William234234
- 515
- 1
- 6
- 15
0
votes
1 answer
Running a Window function on a set of Max'd values
So, I have an object Trainer which has reverse relations to many Survey objects. Each Survey object has a load of Integer fields and represents stats at a certain point in time. Not every Survey object will have every field filled in so I'm using…

JayTurnr
- 157
- 1
- 11
0
votes
2 answers
Postgresql: Insert from huge csv file, collect the ids and respect unique constraints
In a postgresql database:
class Persons(models.Model):
person_name = models.CharField(max_length=10, unique=True)
The persons.csv file, contains 1 million names.
$cat persons.csv
Name-1
Name-2
...
Name-1000000
I want to:
Create the names…

raratiru
- 8,748
- 4
- 73
- 113
0
votes
1 answer
On demand column creation for model in django
So, My models.py has this model
class student(models.Model):
ID = models.CharField(default='DUMMY_ID',primary_key=True,max_length=10)
Score = models.CharField(default='DUMMY_Score',max_length=150)
class =…

Vinay Guda
- 55
- 1
- 1
- 9
0
votes
1 answer
Django postgress - dynamic SearchQuery object creation
I have a app that lets the user search a database of +/- 100,000 documents for keywords / sentences.
I am using Django 1.11 and the Postgres FullTextSearch features described in the documentation
However, I am running into the following problem and…

Jasper
- 2,131
- 6
- 29
- 61
0
votes
1 answer
Handling unique constraint exceptions caused by inserting duplicate values
I have this table (DDL):
CREATE TABLE corpname_skill
(
id SERIAL NOT NULL
CONSTRAINT corpname_skill_pkey
PRIMARY KEY,
guid UUID,
user_id …

Luke
- 1,794
- 10
- 43
- 70
0
votes
1 answer
Adapt JSONField to have auto conversion to Decimal
I have model with fields of type:
django.contrib.postgres.fields.JSONField
and I want have it always deserialized by:
json.loads(value, parse_int=decimal.Decimal, parse_float=decimal.Decimal)
when accessing objects…

Sławomir Lenart
- 7,543
- 4
- 45
- 61
0
votes
1 answer
how to specify an app to migrate to a schema django
I recently did an inspectdb of our old database which is on MySQL. We want to move to postgre. now we want the inspection to migrate to a different schema is there a migrate command to achieve this? so different apps shall use different schemas in…

Blue
- 195
- 1
- 4
- 9
0
votes
1 answer
postgresql error: undefined symbol: GEOSClipByRect in django
when i migrate in djangothe django have return error below
$ python manager.py migrate
django.db.utils.InternalError: could not load library "/usr/lib/postgresql/9.6/lib/postgis-2.3.so": /usr/lib/liblwgeom-2.3.so.0: undefined symbol:…

이경훈
- 39
- 1
- 4
0
votes
1 answer
Set range in IntegerRangeField
I have a model:
from django.contrib.postgres.fields import IntegerRangeField
class Album(models.Model):
rating = IntegerRangeField(default=0)
I want to set maximum and minimum value for default validation purpose. There is already an answer ,…

pyprism
- 2,928
- 10
- 46
- 85
0
votes
1 answer
View execute time is very long (above one minute)
In our Django project, there is a view which creates multiple objects (from 5 to even 100). The problem is that creating phase takes a very long time.
Don't know why is that so but I suppose that it could be because on n objects, there are n…

Milano
- 18,048
- 37
- 153
- 353
0
votes
2 answers
Django Foreign Key not recognising primary key in relation
I have two models, Article and ArticlePost. ArticlePost references Article as a foreign key and is in a separate application to Article:
====app1/models.py:======
class Article(models.Model):
name = models.CharField(max_length=200,…

mohevi
- 63
- 2
- 8
0
votes
1 answer
How to represent a many-to-many mapping as array-field in materialized view in PostgreSQL?
I am trying to create materialized view in postgresql using django by following this blog post.
my models are:
class Occasion(models.Model):
name = models.CharField(max_length=100)
class ItemType(models.Model):
name =…

Amrullah Zunzunia
- 1,617
- 16
- 31
0
votes
3 answers
django orm equivalent for "group by sth. having every(sth.)"
Suppose I have a model "Book" with three fields: name, author_name (as a string), publish_state.
Now I want to find out which authors have exactly one published book. This sql query does exactly what I want:
SELECT author_name from books GROUP BY…
0
votes
1 answer
Does a reverse sql inspector exist for django & postgres
Does a reverse sql inspector exist for django & postgres? Something that shows you what is the origin of the sql view in django?
Something like this: https://github.com/rory/django-sql-inspector, but for postgres.
(Please let me know if you don't…

jackiekazil
- 5,696
- 4
- 21
- 20