2π
β
You could use verbose_name
within the field parameter like this:
nameP = models.CharField(max_length=40, verbose_name='Name')
ageP = models.CharField(max_length=40, verbose_name='Age')
...
You can also do this on Model
classes as well with the Meta
class. Say your Person
class was actually named PPPerson
, like this:
class PPPerson(models.Model):
nameP = models.CharField(max_length=40, verbose_name='Name')
ageP = models.CharField(max_length=40, verbose_name='Age')
class Meta:
verbose_name = 'Person'
verbose_name_plural = 'People'
π€bnjmn
0π
Use the `verbose_nameβ parameter:
class Person(models.Model):
nameP = models.CharField(max_length=40, verbose_name='Name')
ageP = models.CharField(max_length=40, verbose_name='Age')
def __unicode__(self):
return self.nameP
π€jproffitt
0π
You can rename field in model:
- Edit the field name in the model (but remember the old field name: you need it for step 3!)
- Create an empty migration
$ python manage.py makemigrations --empty myApp
- Edit the empty migration (itβs in the migrations folder in your app folder, and will be the most recent migration) by adding to the operations list
migrations.RenameField('MyModel', 'old_field_name', 'new_field_name')
- Apply the migration
$ python manage.py migrate myApp
- [Answered ]-How to override Django-CMS templates
- [Answered ]-Calling tasks recursively on a tree structure
- [Answered ]-Django 1.7: allow_empty_file not working in ImageField
- [Answered ]-Django 1.8.7 get_readonly_fields seems like have a bug
- [Answered ]-ValidationError message doesn't appear in my own form
Source:stackexchange.com