简体   繁体   English

为什么 django 继续将我的应用程序命名为以前的名称?

[英]Why does django continues naming my app as the previous name?

thanks for reading.谢谢阅读。

When I run "py manage.py makemigrations" I get the following message: "ModuleNotFoundError: No module named 'transformaTe'"当我运行“py manage.py makemigrations”时,我收到以下消息:“ModuleNotFoundError: No module named 'transformaTe'”

This is the apps.py code:这是 apps.py 代码:

from django.apps import AppConfig


class TransformateConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'transformate'

The name is updated there and in my INSTALLED_APPS:名称在那里和我的 INSTALLED_APPS 中更新:

INSTALLED_APPS = [
'transformate',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]

Where else should I look to change the name of the app?我还应该在哪里查看更改应用程序的名称?

This is the simplified structure of the app:这是应用程序的简化结构:

\my-app
  \transformate
    admin.py
    apps.py
    models.py
    urls.py
    views.py
   \my-app
     asgi.py
     settigs.py
     urls.py
     wsgi.py

All this happened when I rename the app because I had a problem creating a table called transformaTe_myuser so I though all could be caused by the capitalized letter use.所有这一切都发生在我重命名应用程序时,因为我在创建一个名为 transformaTe_myuser 的表时遇到了问题,所以我认为这一切都可能是由大写字母的使用引起的。

Is there a better way of renaming an existing app in Django?在 Django 中重命名现有应用程序是否有更好的方法? I followed this steps, except for the migration part (Because I deleted the db and the migrations folder): https://odwyer.software/blog/how-to-rename-an-existing-django-application我按照以下步骤操作,除了迁移部分(因为我删除了数据库和迁移文件夹): https://odwyer.software/blog/how-to-rename-an-existing-django-application

Thanks for your help.谢谢你的帮助。

Well, it turns out that when you run makemigrations you have to check the project urls.py file, that was the only thing that was crashing my migrations.好吧,事实证明,当您运行 makemigrations 时,您必须检查项目 urls.py 文件,这是唯一导致我的迁移崩溃的事情。

ORIGINAL my-app/urls.原始我的应用程序/网址。 py FILE:文件:

 from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path('', include('transformaTe.urls')),
    path('admin/', admin.site.urls),
]

NEEDED FILE:需要的文件:

from django.contrib import admin
from django.urls import include, path

urlpatterns = [
    path('', include('transformate.urls')), # Here was the bug
    path('admin/', admin.site.urls),
]

暂无
暂无

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

相关问题 为什么我的 python 应用程序继续收到 500 内部服务器错误? - Why is my python app continues to get a 500 Internal Server Error? App Engine继续提供以前的Python版本 - App Engine continues to serve previous Python version 我的Django应用程序必须与项目目录名称相同吗? - Does my Django app have to be the same name as the project directory? 为什么 Django 不会将应用名称生成到 href 路径中? - Why Django does not generate app name into href paths? 为什么我的Django应用程序在本地工作,而不是在Heroku上工作? - Why does my Django app work locally, but not on Heroku? 为什么图像没有保存在我的 Django 应用程序的数据库中 - Why image does not saved in database in my Django app 为什么需要在Django admin中同时注册应用名称和应用管理员名称? - Why does one need to register both app name and app admin name in Django admin? 为什么Django将2个文件夹命名为项目名称? - Why does Django name 2 folders the project name? 为什么不包含我的追加列表? 我试图在循环时继续向列表中添加更多项目,但是当循环继续时,它就消失了 - why does it not contain my append list? im trying to continue adding more items to the list while looping but when it the loop continues it vanishes 为什么我的 django 应用程序无法部署到 heroku(“为 psycopg2 构建轮子”)? - Why does my django app fail to deploy to heroku ("building wheel for psycopg2")?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM