Skip to content

Tag: django-admin

Catch IntegrityError in Django Admin

Working with Django 1.4 I would like to catch an Integrity Error when a user does enter a duplicate value. At this moment the application just shows the default Django error page. (debug = True) model admin form At this moment I get an error page showing a ValidationError instead of an IntegrityError. (Which …

Django admin is_staff based on group

Is it possible to have is_staff selected by choosing a group? Let’s say there are two groups: users, admins When a new user is in the users group he is not staff, but if he is in the admins group he is staff. Answer I managed to make it work by extending the UserAdmin class and in the get_form function

Change Python Class attribute dynamically

I have a Class B inheriting Class A with a class attribute cls_attr. And I would like to set dynamically cls_attr in class B. Something like that: I tried several things. I know i might not be looking in the right place but i am out of solutions. EDIT: Classes are django admin classes Thanks. Answer class att…

Nothing happens when I do: python manage.py command

I’m new to django and currently going through the main tutorial. Even though it was working earlier, when I do python manage.py runserver OR python manage.py -h OR with any other command, the shell doesn’t output anything. Wondering what I’m doing wrong. Answer First, check if python is full…

How to use can_add_related in Django Admin

I’ve read about the can_add_related feature here: https://code.djangoproject.com/ticket/9071 I tried using it this way: But this throws a TypeError and I don’t know how to solve this. Can someone point me in the right direction? Thank you. Answer This is probably coming in late. But for other view…

Paginator for inline models in django admin

I have this simple django model consisting of an sensor and values for the specific sensor. The number of values per Pyranometer is high (>30k). Is it somehow possible to paginate PyranometerValues by a specific day or generell apply a paginator to the admin inline view? Answer Have you checked raw_id_fiel…