Reputation: 2107
I have a django model in my app that looks like this(assuming all required modules are imported)
class profile(models.Model):
user = models.OneToOneField(User)
mobile_regex = RegexValidator(regex=r'^\+?1?\d{9,15}$', message="phone number must be entered in hte format '+23474857934'. Up to 15 digits allowed")
mobile = models.CharField(validators=[mobile_regex], max_length=15, blank=True, null=True)
I made a (silly)mistake spelling the profile name(using a lowercase to start the model name instead of uppercase), and would like to correct this, is there a way to this without affecting the data that might already be stored.
changing the name from profile to Profile and making a migration doesn't reflect the change, and I don't get the usual..
"Did you rename appname.oldModelName
to appname.NewModelName
? [y/N]" query
I'm sorry if this question seems a bit trivial,I'm a newbie at django thanks for understanding
Upvotes: 1
Views: 845
Reputation: 2107
I found a way to work around this
Django does not recognize a rename if you only change the letter case so, these steps helped me solved the problem:
change the name of the model completely(Something simple like 'temp'), and run the makemigrations
command (this will be recognized and django will ask you if you want to rename- enter 'y')
then change it back this time using the proper casing for the letters
then run the makemigrations
command again. and rename.
This only affects the model name and not the table name in your actual database(these are usually named in all lowercase by default)
Upvotes: 1