Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django loaddata returns a permission denied for relation

I am trying to load some data from a json file generated from a dumpdata on a django project to a new one with a new database using loaddata. The connection to the db seems to work but almost right away I receive a permission denied for relation django_content_type. I don't get what permission we are talking about. the db is postgres on a separate server and I connect to it through a vagrant virtual machine on my laptop that has a virtual environment and the settings.py has the settings to connect to the db. Here is the Traceback:

Problem installing fixture 'djgprd1_dumpdata.json': Traceback (most recent call last):
  File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 196, in handle
    obj.save(using=using)
  File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/core/serializers/base.py", line 165, in save
    models.Model.save_base(self.object, using=using, raw=True)
  File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/db/models/base.py", line 524, in save_base
    manager.using(using).filter(pk=pk_val).exists())):
  File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/db/models/query.py", line 565, in exists
    return self.query.has_results(using=self.db)
  File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/db/models/sql/query.py", line 441, in has_results
    return bool(compiler.execute_sql(SINGLE))
  File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 818, in execute_sql
    cursor.execute(sql, params)
  File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/db/backends/util.py", line 40, in execute
    return self.cursor.execute(sql, params)
  File "/home/vagrant/devenv/local/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py", line 52, in execute
    return self.cursor.execute(query, args)
DatabaseError: Could not load contenttypes.ContentType(pk=29): permission denied for relation django_content_type

What am I doing wrong here?

like image 672
Bastian Avatar asked Nov 23 '25 05:11

Bastian


1 Answers

The postgres user for this db was created automatically and I did not check the permissions, they were missing for this db so a GRANT ALL PRIVILEGES ON DATABASE x for user y; resolved the permissions problem. My bad.

like image 191
Bastian Avatar answered Nov 25 '25 20:11

Bastian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!