I'm trying to dump my database (sqlite3) to a json file for a fixture, but I have an unmanaged model which is causing a no such table
error (obviously!) so how do you dumpdata with these kind of models in the 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
Just exclude this model using --exclude
option. Quote from 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With