Unmanaged model dump

I am trying to dump my database (sqlite3) into a json file for a device, but I have an unmanaged model that causes a no such table error (obviously!), Since you dumpdat with these types of models in db?

Model:

 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 

Error:

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

+6
source share
1 answer

Just exclude this model with the --exclude . Quote from docs :

The -exclude option can be provided to prevent certain applications or models (specified as appname.ModelName) from being reset. If you specify a model name for dumpdates, the drop-down output will be limited to this model, and not to the entire application. You can also mix application names and model names.

 ./manage.py dumpdata myApp --exclude=myApp.Backup 
+8
source

Source: https://habr.com/ru/post/952026/


All Articles