Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i remove extra "s" from django admin panel?

I am really very much irritated by the extra "s" added after my class name in django admin eg class 'About' in my model.py becomes 'Abouts' in admin section. And i want it not to add extra 's'. Here is my model.py file-

class About(models.Model):
        about_desc = models.TextField(max_length=5000)

        def __unicode__(self):              # __str__ on Python 3
                return str(self.about_desc)

Please anybody suggest me how django can solve my problem.

like image 475
Rahul Rathi Avatar asked Aug 17 '15 10:08

Rahul Rathi


People also ask

Can we customize Django admin panel?

The Django admin is a powerful built-in tool giving you the ability to create, update, and delete objects in your database using a web interface. You can customize the Django admin to do almost anything you want.

How customize Django admin CSS?

In your static directory, create a static/admin/css/base. css file. Paste in Django's default Admin CSS first, then add your customizations at the bottom. If you do this, be sure to put your app BEFORE django.

How do I restrict access to admin pages in Django?

Django admin allows access to users marked as is_staff=True . To disable a user from being able to access the admin, you should set is_staff=False . This holds true even if the user is a superuser. is_superuser=True .

How do I delete a record in Django?

To delete a record we do not need a new template, but we need to make some changes to the members template. Of course, you can chose how you want to add a delete button, but in this example, we will add a "delete" link for each record in a new table column. The "delete" link will also contain the ID of each record.


1 Answers

You can add another class called Meta in your model to specify plural display name. For example, if the model's name is Category, the admin displays Categorys, but by adding the Meta class, we can change it to Categories.

I have changed your code to fix the issue:

class About(models.Model):

    about_desc = models.TextField(max_length=5000)

    def __unicode__(self):              # __str__ on Python 3
        return str(self.about_desc)

    class Meta:
        verbose_name_plural = "about"

For more Meta options, refer to https://docs.djangoproject.com/en/1.8/ref/models/options/

like image 84
Abhyudit Jain Avatar answered Oct 11 '22 12:10

Abhyudit Jain