stacklens / dusai-blog

杜赛的博客的评论区。详情见 Issue。
2 stars 0 forks source link

article/15/ #5

Open stacklens opened 4 years ago

stacklens commented 4 years ago

https://www.dusaiphoto.com/article/15/

stacklens commented 4 years ago

旧评论区读者提问集中贴:


注意下面这个非常多人遇到的问题!

Q:报告一个错误:

非教程错误,是Django的bug,在Django2.1 版本下迁移数据表,然后在Django控制台添加数据会出现 django.db.utils.OperationalError: no such table: main.auth_user__old 的错误。

解决办法: 将sqlite中除system catalogue下的所有表全删掉,然后安装Django2.1.5,重新迁移数据,运行。

A:这个错误确实是由于 django 2.1 和 splite 版本兼容性引起的,换一个 Django 版本即可。感谢您的评论,给其他人提个醒


Q:后台添加文章后不显示标题名,只显示 ArticlePost object 。

A:model里没写 str() 方法。


Q:博主,继之前数据同步的错误后,继续走还是一堆bug,是因为代码没完善的原因吗?

(env) D:\django_project\my_blog>python manage.py createsuperuser
Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "D:\django_project\env\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "D:\django_project\env\lib\site-packages\django\core\management\__init__.py", line 357, in execute
    django.setup()
  File "D:\django_project\env\lib\site-packages\django\__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "D:\django_project\env\lib\site-packages\django\apps\registry.py", line 112, in populate
    app_config.import_models()
  File "D:\django_project\env\lib\site-packages\django\apps\config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "C:\Users\jiaxin\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "D:\django_project\my_blog\article\models.py", line 5, in <module>
    class ArticlePost(models.Model):
  File "D:\django_project\my_blog\article\models.py", line 6, in ArticlePost
    author = models.Foreignkey(User, on_delete=models.CASCADE)
AttributeError: module 'django.db.models' has no attribute 'Foreignkey'

A:是 ForeignKey

不是 Foreignkey

Lykisun commented 3 years ago

SQL打开显示:itestudio[16:47:37] 未能将数据'D:\FileData\Codefile\python\venv\my_blog\db.sqlite3'添加到列表

hi-nikola commented 2 years ago

打卡!!!写的真好!

hi-nikola commented 2 years ago

大家直接用 mysql 数据库吧 很方便修改

KSroido commented 2 years ago

不太懂一个问题 “反查url” 是什么意思? 或者说,是有正查url的操作的么