在应用程序上运行manage.py dumpdata,其名称中带有点

时间:2021-07-17 18:03:51

I'm trying to do moving some data from my development machine to a server using dumpdata but ran into a problem. So, say I want to dump the data that belongs to the app django.contrib.auth.
django.contrib.auth is in my INSTALLED_APPS.
This happens when I run
$ python manage.py dumpdata django.contrib.auth

我正在尝试使用dumpdata将一些数据从我的开发机器移动到服务器,但遇到了问题。所以,假设我要转储属于app django.contrib.auth的数据。 django.contrib.auth在我的INSTALLED_APPS中。当我运行$ python manage.py dumpdata django.contrib.auth时会发生这种情况

Error: Unknown application: django.contrib.auth

错误:未知应用程序:django.contrib.auth

The strange thing is that I can do manage.py testserver (i.e. nothing is broken) or do
$ python
>>> import django.contrib.auth

So there is nothing wrong with the python path.
I can run dumpdata on apps that are located straight in my project's dir.
If I leave out the apps' names, django.contrib.auth's tables are dumped as expected.

奇怪的是,我可以做manage.py testserver(即什么都没有被破坏)或者执行$ python >>> import django.contrib.auth所以python路径没有任何问题。我可以在直接位于项目目录中的应用程序上运行dumpdata。如果我省略了应用程序的名称,django.contrib.auth的表将按预期转储。

So, why can't I point out a specific app with dots in the name? I have tried to dump other apps that are located in site-packages with the same result.

那么,为什么我不能指出名称中带点的特定应用?我试图转储位于site-packages中的其他应用程序具有相同的结果。

1 个解决方案

#1


22  

Try instead:

尝试改为:

python manage.py dumpdata auth

The dumpdata command doesn't require the (fully qualified) package name of the app, only the name.

dumpdata命令不需要应用程序的(完全限定的)程序包名称,只需要名称。

#1


22  

Try instead:

尝试改为:

python manage.py dumpdata auth

The dumpdata command doesn't require the (fully qualified) package name of the app, only the name.

dumpdata命令不需要应用程序的(完全限定的)程序包名称,只需要名称。