django-admin

Link from Django Model's "absolute url" to its admin page

Link from Django Model's "absolute url" to its admin page Question: According to the docs, you can specify a get_absolute_url in your Django Model for a "View on site" button to show up on Django Admin. However, how would you do the opposite? A link on the above defined "absolute url" that takes you to …

Total answers: 1

How to create clickable links for foreign keys in Django admin panel?

How to create clickable links for foreign keys in Django admin panel? Question: How to make foreign keys clickable in Django admin list view to open related detail admin page? Currently, Django admin displays foreign keys as plain text in the list view. Is there a way to make these foreign keys clickable links that …

Total answers: 1

django sub admin panel

django sub admin panel Question: I am working on the Django admin panel but now client is asking me that he need a functionality to create sub admin from the admin panel and provide some permission to sub admin flow – Here admin need a tab like sub admin management- admin will be able to …

Total answers: 1

Filter queryset based on related object's field value

Filter queryset based on related object's field value Question: I have two models: class PartUse(models.Model): … imported = models.BooleanField() class PartReturn(models.Model): partuse = models.ForeignKey(PartUse) … imported = models.BooleanField() class PartUseListView(ListView): model = PartUse def get_queryset(self): if self.request.GET.get(‘show_imported’, None): qs = self.model.objects.all() else: qs = self.model.objects.filter(Exists(PartReturn.objects.filter( imported=False, id__in=OuterRef("partreturn")))) return qs I want to filter QuerySet for …

Total answers: 1

Django SimpleListFilter: ValueError not enough values to unpack (expected 2, got 0)

Django SimpleListFilter: ValueError not enough values to unpack (expected 2, got 0) Question: Context: I’m creating a custom input filter in Django using the SimpleListFilter class. I’ve followed the steps in here https://hakibenita.com/how-to-add-a-text-filter-to-django-admin, but I’m encountering a ValueError when trying to use the filter. Here is my code: filters.py: from django.contrib import admin from django.db.models …

Total answers: 1

How to set ordering of Apps and models in Django admin dashboard

How to set ordering of Apps and models in Django admin dashboard Question: i would like to set a specific order of the models list of an app in the django dashboard. my models look like this: i’ve tried several tutorial like this one and looked other people solution inside SO like this questions How …

Total answers: 1

Overriding django admin get_queryset()

Overriding django admin get_queryset() Question: I have two models which is one of them proxy model. In admin I registered both and overrided get_queryset() method but it is not working as expected. admin.py @admin.register(Category) class CategoryAdmin(admin.ModelAdmin): def get_queryset(self, request): qs = super().get_queryset(request) return qs.filter(language=’en’) @admin.register(ProxyCategory) class ProxyCategoryAdmin(CategoryAdmin): def get_queryset(self, request): qs = super().get_queryset(request) return qs.filter(language=’zh’) …

Total answers: 2

How to add icons or emoji in django admin buttons

How to add icons or emoji in django admin buttons Question: So I have some buttons in django admin and I need to add something like that: ⬅️➡️↩️↪️ to my admin buttons, but I have 0 idea how to do this and I feel like I am the first ever person to ask that question …

Total answers: 1