Django – How to access the verbose_name of a Model in its Admin Module?

Model._meta.verbose_name.title() and Model._meta.verbose_name_plural.title() return singular and plural Model’s verbose names accordingly. There’s also Model._meta.verbose_name_raw property, it seems to return unicode string for me, while verbose_name.title() returns a normal string, but I’m not sure what’s the real difference between this and verbose_name.title().

Django Admin: How to access the request object in admin.py, for list_display methods?

I solve my issue this way (for django under 1.7): class MyClassAdmin(admin.ModelAdmin): def queryset(self, request): qs = super(MyClassAdmin, self).queryset(request) self.request = request return qs Now i can use self.request in any place UPDATE Changed in Django 1.6: The get_queryset method was previously named queryset. class MyClassAdmin(admin.ModelAdmin): def get_queryset(self, request): qs = super(MyClassAdmin, self).get_queryset(request) self.request = … Read more

How to use custom AdminSite class?

The Problem Using a custom class derived from django.contrib.admin.AdminSite for the admin site of a project, without having to write custom registration code to register models with the new class. When I use 3rd party apps with their own models, I’d rather not have to edit custom registration code only because models were added or … Read more

PermissionError: [Errno 13] Permission denied: ‘/manage.py’

ubuntu 21.04 I got here searching for PermissionError: [Errno 13] Permission denied: so i’ll just leave this here. note: the below answer doesn’t work for multi user systems … see this answer instead for another possible solution If you want to set it and forget it for 1 user, your own user … here’s what … Read more

How can I add a button into django admin change list view page

When several applications provide different versions of the same resource (template, static file, management command, translation), the application listed first in INSTALLED_APPS has precedence. – Django documentation on INSTALLED_APPS Make sure your app is listed before ‘django.contrib.admin’ in INSTALLED_APPS. Create a change_list.html template in one of the following directories: # Template applies to all change … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)