Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change model class name in Django admin interface [duplicate]

Tags:

django

Possible Duplicate:
Verbose name for admin model Class in django

I had a model with a class like:

class Anh_chi_tiet(models.Model):     du_an       = models.ForeignKey(Du_an)     title       = models.CharField(max_length=120)     url         = models.ImageField(upload_to='images')     url_detail  = models.ImageField(upload_to='images') 

When I go to admin interface, my Anh_chi_tiet class has a label: Anh_chi_tiets (added s suffix) But I want to change my class label to "My image"

How can I do that?

like image 603
Son Tran Avatar asked Dec 03 '11 16:12

Son Tran


People also ask

How do I change app label in Django admin?

Rename the folder which is in your project root. Change any references to your app in their dependencies, i.e. the app's views, the urls.py and settings.py files. Edit the database table django_content_type with the following command: UPDATE django_content_type SET app_label='' WHERE app_label=''

How can I remove extra's from Django admin panel?

Take a look at the Model Meta in the django documentation. Within a Model you can add class Meta this allows additional options for your model which handles things like singular and plural naming. Show activity on this post. inside model.py or inside your customized model file add class meta within a Model Class.

Can we change Django admin theme?

To do so, you will have to change the project's settings.py . Find the TEMPLATES section and modify accordingly. To override the default template you first need to access the template you want to modify from the django/contrib/admin/templates/admin directory.


1 Answers

Via inner Meta class, as documented:

class Anh_chi_tiet(models.Model):     # ... fields ...      class Meta:         verbose_name = 'My image'         verbose_name_plural = 'My images' 
like image 179
Cat Plus Plus Avatar answered Sep 23 '22 15:09

Cat Plus Plus