Questions tagged [django-postgresql]

Use this tag for PostgreSQL issues which are to be solved in accordance with Django coding best practices.

207 questions
5
votes
2 answers

Django Admin Model ArrayField Change Delimiter

My model looks like this: from django.contrib.postgres.fields import ArrayField class Trigger(models.Model): solutions = ArrayField(models.TextField(blank=True, null=True), blank=True, null=True, help_text='some helpful text') This allows me…
5
votes
3 answers

Django ArrayField with different types

I need to configure a django.contrib.postgres.fields.ArrayField with a list of pairs in which the fist element is a float and the second, a small positive integer: data = [[1.23, 3], [2.42, 1], [3.72, 29]] How could I do this? Is it possible? I…
msampaio
  • 3,394
  • 6
  • 33
  • 53
5
votes
2 answers

'django_postgrespool' isn't an available database backend

After installing django_postgrespool and configuring my project accordingly, I received the following error: Traceback (most recent call last): File "C:\Users\Administrator\Documents\my_proj\my_module.py", line 14, in from…
Jonathan Livni
  • 101,334
  • 104
  • 266
  • 359
5
votes
1 answer

Error: No module named psycopg2.extensions django postgresql

I want to Use PostgreSQl With Django . I referred this tutorial to install it and when I run this command python manage.py syncdb I get the following errors Traceback (most recent call last): File "manage.py", line 10, in
user2528042
  • 419
  • 2
  • 6
  • 12
5
votes
1 answer

Django - How to get debug info of DatabaseError "current transaction is aborted" in Django error page?

While developing on my Django project I'm getting a DatabaseError that says: current transaction is aborted, commands ignored until end of transaction block I know this happens because there was a bad PostgreSQL transaction without a rollback…
gitaarik
  • 42,736
  • 12
  • 98
  • 105
4
votes
1 answer

How to store HStore field properly?

Here I have a HStoreField which will be taken from user Input. User gives the input in the format s:Small,l:Large, But I think the HStoreField needs the data type like this{'s': 'Small','l':'Large'}. How can I covert the user data into this format…
D_P
  • 802
  • 10
  • 32
4
votes
1 answer

Convert the value of a field in a django RawQueryset to a different django field type

I have a rather complex query that's generating a Django RawQuerySet. This specific query returns some fields that aren't part of the model that the RawQuerySet is based on, so I'm using .annotate(field_name=models.Value('field_name')) to attach it…
4
votes
1 answer

Why do different Django Models with JSONFields have the same values?

I've got a model with a JSONField (a Postgres only field): models.py: from django.db import models from django.contrib.postgres.fields import JSONField class Mod(models.Model): data = JSONField(default={ 'name':'Model' }) So I create 2 models…
4
votes
3 answers

How to do an accent-insensitive TrigramSimilarity search in django?

How can I add accent-insensitive search to following snippet from the django docs: >>> from django.contrib.postgres.search import TrigramSimilarity >>> Author.objects.create(name='Katy Stevens') >>> Author.objects.create(name='Stephen Keats') >>>…
Private
  • 2,626
  • 1
  • 22
  • 39
4
votes
2 answers

Django: ProgrammingError relation does not exists

To setup new database on heroku I tried python manage migrate and got many exceptions related to relation already exists/does not exists. So I followed the instructions here django 1.9: ProgrammingError: relation "users_user" does not exist but it…
Ibrahim
  • 287
  • 1
  • 3
  • 13
4
votes
0 answers

SQL Index on Django Generic Relation

Is it possible/sensible to create an SQL index on a GenericForeignKey in a Django model? I want to perform a lookup on a large number of (~1 million) objects in my postgreSQL database. My lookup is based on a GenericForeignkey on the relevant model,…
Jonathan Evans
  • 1,173
  • 2
  • 10
  • 22
4
votes
2 answers

How to make a geography field unique?

I have this model: class Marker(models.Model): location = models.PointField(geography=True, unique=True) When I try to add a Marker instance through the admin interface, it raises a ValueError: File "django/core/handlers/base.py" in…
borges
  • 3,627
  • 5
  • 29
  • 44
4
votes
1 answer

Django saving form strings in database with extra characters (u'string')

I've been having problems in django while trying to save the form.cleaned_data in a postgres database. user_instance.first_name = form.cleaned_data['first_name'] the data is being saved this way (u'Firstname',) with the 'u' prefix and parenthesis…
4
votes
1 answer

Django creates the test database for Postgresql with incorrect sequences start values

Using pyscopg2, as Django database default backend, and with very simple case for a test. It fails trying to create a user, with a IntegrityError exception $ python manage.py test project.core.tests nosetests --verbosity 1 project.core.tests…
Mario César
  • 3,699
  • 2
  • 27
  • 42
3
votes
0 answers

Django ORM - Primary key not available after save while using UUIDField and RandomUUID In Postgres

For a project I'm working on, in one of the models i am using models.UUIDField for primary key with the default value set to django.contrib.postgres.functions.RandomUUID Here's my model. from django.contrib.postgres.functions import RandomUUID from…
1 2
3
13 14