简体   繁体   English

使用cookiecutter-django创建的项目未运行

[英]Project created using cookiecutter-django not running

Its been a few months that I am trying to learn Django. 我尝试学习Django已经几个月了。 In the same process (and while reading "Two Scoops of Django 1.11"), I came across Cookiecutter Django. 在相同的过程中(并且在阅读“ Django 1.11的两个瓢”时),我遇到了Cookiecutter Django。 It has helped me learn a few important things to keep in mind while creating a project. 它帮助我学习了创建项目时要记住的一些重要事项。

I tried to run the template provided by cookiecutter-django but failed. 我试图运行cookiecutter-django提供的模板,但失败了。 Here are the steps that I followed. 这是我遵循的步骤。

  1. Create a virtual environment named test and activate it. 创建一个名为test的虚拟环境并激活它。

mkvirtualenv test

  1. Installed Cookiecutter . 安装了Cookiecutter

pip install coockiecutter

  1. Installed Cookiecutter Django , The project name was set to "Test Project" and other defaults settings were chosen. 已安装Cookiecutter Django ,项目名称设置为“ Test Project”,并选择了其他默认设置。 I am using PostgreSQL 9.6. 我正在使用PostgreSQL 9.6。 cookiecutter https://github.com/pydanny/cookiecutter-django
  2. Create a database named "test_project" in PostgreSQL. 在PostgreSQL中创建一个名为“ test_project”的数据库。
  3. Run python manage.py migrate 运行python manage.py migrate

The result was the error: 结果是错误:

django.db.utils.OperationalError: FATAL:  role "dev" does not exist

I have also tried making a user named test_project_user and granting it all the privileges to test_project database. 我还尝试过创建一个名为test_project_user的用户,并将其所有特权授予test_project数据库。 I am still getting the same error. 我仍然遇到相同的错误。

The problem seems to be that you specified a database user that does not exist (or you left blank and it assumes your system user), in: 问题似乎是您在以下位置中指定了一个不存在的数据库用户(或者您留空并假定您是系统用户):

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'test_project',
        'USER': 'HERE', # Set test_project_user here
        ...
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM