Django 1.8与postgres迁移错误
我是Django的新手,我正尝试使用Django(1.8)在Postgre中创建表格,
以下是我的模特班
class Student(models.Model):
name = models.CharField(max_length = 50)
degree = models.CharField(max_length = 50)
numofsubs = models.IntegerField()
namesofsubs= models.CharField(max_length = 50)
details = models.CharField(max_length = 50)
class Meta:
db_table = "student"
views.py
def addStudent(request):
student = Student(name = request.name, degree = request.degree ,
numofsubs = request.numofsubs , nameofsubs = request.nameofparams , details = request.details)
student.save()
print 'data saved'
当我试图运行python manage.py migrate时发生这些更改后,我得到了django.db.utils.ProgrammingError: permission denied for relation django_migrations
以下是堆栈跟踪
Traceback(最近的最后一次调用):execute_from_command_line(sys.argv)中的文件“manage.py”,第10行文件“/usr/lib/ckan/default/local/lib/python2.7/site-packages/django/芯/管理/ 初始化 py “为,线338,在execute_from_command_line utility.execute()文件” /usr/lib/ckan/default/local/lib/python2.7/site-packages/django/core/management/ INIT。 py“,第330行,执行self.fetch_command(子命令).run_from_argv(self.argv)文件”/usr/lib/ckan/default/local/lib/python2.7/site-packages/django/core/management/ base.py“,行390,在run_from_argv self.execute(* args,** cmd_options)文件”/usr/lib/ckan/default/local/lib/python2.7/site-packages/django/core/management/ base.py“,第441行,执行output = self.handle(* args,** options)文件”/usr/lib/ckan/default/local/lib/python2.7/site-packages/django/core/管理/命令/ migrate.py“,第93行,处理executor = MigrationExecutor(connection,self.migration_progress_callback)文件”/usr/lib/ckan/default/local/lib/python2.7/site-packa ges / django / db / migrations / executor.py“,第19行,在init中 self.loader = MigrationLoader(self.connection)文件”/usr/lib/ckan/default/local/lib/python2.7/site-packages /django/db/migrations/loader.py“,第47行,在init self.build_graph()文件中”/usr/lib/ckan/default/local/lib/python2.7/site-packages/django/db/migrations /loader.py“,第180行,在build_graph self.applied_migrations = recorder.applied_migrations()文件中”/usr/lib/ckan/default/local/lib/python2.7/site-packages/django/db/migrations/recorder .py“,第60行,在applied_migrations中返回set(tuple(x)for self in.migration_qs.values_list(”app“,”name“))File”/ usr / lib / ckan / default / local / lib / python2 .7 / site-packages / django / db / models / query.py“,第162行,在iter self._fetch_all()文件中”/usr/lib/ckan/default/local/lib/python2.7/site-packages /django/db/models/query.py“,第965行,在_fetch_all self._result_cache = list(self.iterator())文件中”/usr/lib/ckan/default/local/lib/python2.7/site- packages / django / db / models / query.py“,第1220行,in iterator for row in compiler.results_iter():文件“/usr/lib/ckan/default/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py”,第783行,in results_iter results = self.execute_sql(MULTI)文件“/usr/lib/ckan/default/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py”,第829行,在execute_sql cursor.execute(sql,params)文件“/usr/lib/ckan/default/local/lib/python2.7/site-packages/django/db/backends/utils.py”,第79行,在execute return super( CursorDebugWrapper,self).execute(sql,params)文件“/usr/lib/ckan/default/local/lib/python2.7/site-packages/django/db/backends/utils.py”,第64行,执行返回self.cursor.execute(sql,params)文件“/usr/lib/ckan/default/local/lib/python2.7/site-packages/django/db/utils.py”,行97, 退出六。重新执行(dj_exc_type,dj_exc_value,traceback)在执行返回自我中的文件“/usr/lib/ckan/default/local/lib/python2.7/site-packages/django/db/backends/utils.py”,第64行。 cursor.execute(sql,params)django.db.utils.Progra mmingError:针对关系django_migrations拒绝了权限
我的settings.py
对db连接具有以下conf
DATABASES = {
'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'abc',
'USER': 'xyz',
'PASSWORD': 'xxxxx',
'HOST': 'localhost',
'PORT': 5432,
}
}
请指导我什么是我的应用程序错误。
谢谢
可能是你需要允许你的用户:
GRANT ALL ON DATABASE abc TO xyz;
我不会建议做一个GRANT ALL。 但是,正如Bear Brown指出的那样,这听起来像是权限问题,所以请确保您至少具有相关架构的USAGE和表的SELECT特权。 首先连接到abc数据库,然后授予public选择权限:
GRANT SELECT ON ALL TABLES IN SCHEMA public TO xyz
链接地址: http://www.djcxy.com/p/86475.html