[Django]-Django: Overriding verbose_name for AutoField without dropping the model

4👍

Hmm… and what about explicitly write id field in the model definition? Like this for example:

class Entry(models.Model):
   id = models.AutoField(verbose_name="custom name")
   # and other fields...

It doesn’t require any underlying database changes.

2👍

Look into the command-line options for manage.py; there’s a command to dump all of the model data to JSON, and another command to load it back in from JSON. You can export all of your model data, add your new field to the model, then import your data back in. Just make sure that you set the db_column option to 'id' so you don’t break your existing data.

Edit: Specifically, you want the commands dumpdata and loaddata.

Leave a comment