2013-08-19 119 views
6

我試圖將我的數據庫(sqlite3)轉儲到夾具的json文件,但我有一個非託管模型導致no such table錯誤(顯然!),那麼如何dumpdata這些類型數據庫中的模型?Dumpdata與非託管模型

型號:

from django.db import models 


class Backup(models.Model): 
    """ 
    This class is lazily recycled between various forms that ask the user to 
    provide a path to some data. 
    """ 

    dbloc = models.CharField(
     max_length = 255 
    ) 

    class Meta: 
     app_label = 'myApp' 
     db_table = 'backup' 
     managed = False 

錯誤:

​​

回答

8

只排除使用--exclude選擇這種模式。從docs報價:

The --exclude option may be provided to prevent specific applications or models (specified as in the form of appname.ModelName) from being dumped. If you specify a model name to dumpdata, the dumped output will be restricted to that model, rather than the entire application. You can also mix application names and model names.

./manage.py dumpdata myApp --exclude=myApp.Backup 
+1

我需要停下來這裏閱讀文檔之前!謝謝你:D –