如何使用PyCharm构建Pinry(Python/Django Pinterest克隆)?

0 投票
1 回答
1361 浏览
提问于 2025-04-18 16:20

在我开始之前,请原谅我这个完全新手的问题(我需要一些简单的步骤)。我最近开始学习Python和Django框架,使用像Codecademy和Pluralsight这样的工具。我希望通过在我的Python开发环境PyCharm中运行Pinry(一个类似Pinterest的应用)来深入了解这个过程,并尝试根据我目前学到的知识进行一些修改,看看会发生什么。不幸的是,我下载了最新版本的Pinry,但在我的本地机器上尝试在PyCharm中运行时,遇到了各种错误。

以下是我所采取的步骤:

  1. 我已经安装并配置好了Python、Django和PyCharm。
  2. 下载了Pinry的新副本,并在PyCharm中打开了这个目录。
  3. 点击“运行” - “编辑配置”。
  4. 点击“+”按钮添加一个新配置,勾选“运行浏览”,选择Python解释器(带Django),然后点击“修复”以启用项目的Django支持。
  5. 在项目的Django设置中,添加Django项目的根目录、设置和管理脚本。
  6. 最后按下alt/option + R,运行服务器以启动应用。
  7. 到这一步,我本以为程序会正常运行,但却出现了下面的错误列表。

有没有人成功在PyCharm中运行Pinry,而不需要修改任何代码?我不太确定这些问题是出在这个包上,还是需要在PyCharm中修改设置才能让它正常工作。有什么见解吗?

谢谢大家!

File "/Applications/PyCharm.app/helpers/pycharm/django_manage.py", line 23, in <module>
    run_module(manage_file, None, '__main__', True)


File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 176, in run_module
    fname, loader, pkg_name)


File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals

File "/Users/hussein/Desktop/pinry-master/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/base.py", line 279, in execute
    saved_locale = translation.get_language()

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 154, in get_language
    return _trans.get_language()

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 52, in __getattr__
    if settings.USE_I18N:

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
    self._setup(name)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in _setup
    self._wrapped = Settings(settings_module)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py", line 151, in __init__
    raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

1 个回答

0

在PyCharm中,进入“项目设置/Django”,在“设置”字段里指定“settings/development.py”。

撰写回答