2013-08-19 23 views
6

Veritabanımı (sqlite3) bir fikstür için bir json dosyasına dökmeye çalışıyorum, ancak bir no such table hatasına neden olan yönetilmeyen bir modelim var (açıkçası!) Bu yüzden bu tür dökümlerle nasıl uğraşıyorsunuz? db modellerin?Yönetilmeyen modellerle Dumpdata

Modeli:

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 

Hata:

CommandError: Unable to serialize database: no such table: backup

cevap

8

Sadece --exclude seçeneğini kullanarak bu modeli dahil değildir. docs alıntı:

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

Ben dokümanlar okumadan önce buraya gelen durdurmak gerekiyor! Teşekkür ederim: D –

İlgili konular