Questions tagged [django-admin]

Django's built-in, automatic admin interface (django.contrib.admin) which is part of the Django Web framework for the Python programming language.

One of the most powerful parts of Django is the automatic admin interface. It reads metadata from your models to provide a quick, model-centric interface where trusted users can manage content on your site. The admin’s recommended use is limited to an organization’s internal management tool. It’s not intended for building your entire front end around.

-- Django Admin Documentation

Resources:

10185 questions
66
votes
4 answers

testing admin.ModelAdmin in django

I am trying to find out the best way for testing admin.ModelAdmin in admin.py. Specifically I am overriding the save_model() function which I want to test. From the research I have done, the only solution I have found was writing a request/response…
instigator
  • 1,587
  • 5
  • 15
  • 27
66
votes
8 answers

Django Admin nested inline

I need a nested django admin inline, which I can include the date field inlines in an other inline like below. I have the models below: class Person(models.Model): name = models.CharField(max_length=200) id_no =…
tuna
  • 6,211
  • 11
  • 43
  • 63
66
votes
2 answers

Linking to the django admin site

Very basic question, but I'm having trouble tracking down the answer on the web. I have a template, which I want to link to the django admin site (i.e. localhost:8000/admin). What is the code for this? I'm imagining something like
Rowena
65
votes
5 answers

Django. You don't have permission to edit anything

I created a little app a while ago. I created admin.py and used admin.site.register(MenuEntry) to add the class to admin console. It showed the items of that class just fine. Then I began working on another app and created everything as before. But…
Sergei Basharov
  • 51,276
  • 73
  • 200
  • 335
65
votes
4 answers

is there a simple way to get group names of a user in django

I tried following Code with the help of the django.contrib.auth.User and django.contrib.auth.Group for g in request.user.groups: l.append(g.name) But that failed and I received following Error: TypeError at / 'ManyRelatedManager' object is not…
icn
  • 17,126
  • 39
  • 105
  • 141
63
votes
6 answers

Django - How to specify which field a validation fails on?

I have this model I'm showing in the admin page: class Dog(models.Model): bark_volume = models.DecimalField(... unladen_speed = models.DecimalField(... def clean(self): if self.bark_volume < 5: raise…
Greg
  • 45,306
  • 89
  • 231
  • 297
62
votes
13 answers

Getting Site Matching Query Does Not Exist Error after creating django admin

I'm going through the standard Django tutorial to create an admin for an app. After commenting the admin related stuff in settings and running syncdb I'm getting this message: DoesNotExist at /admin/ Site matching query does not exist. Can anyone…
David Haddad
  • 3,796
  • 8
  • 32
  • 40
60
votes
7 answers

Django Admin linking to related objects

My app has users who create pages. In the Page screen of the admin, I'd like to list the User who created the page, and in that list, I'd like the username to have a link that goes to the user page in admin (not the Page). class…
Brenden
  • 8,264
  • 14
  • 48
  • 78
59
votes
18 answers

"No installed app with label 'admin'" running Django migration. The app is installed correctly

I am trying to use admin.LogEntry objects during a datamigration on Django 1.7 The 'django.contrib.admin' app is listed on INSTALLED_APPS. On the shell, it works: >>> from django.apps import apps >>> apps.get_model('admin',…
alanjds
  • 3,972
  • 2
  • 35
  • 43
59
votes
6 answers

coercing to Unicode: need string or buffer, NoneType found when rendering in django admin

I have this error since a long time but can't figure it out : Caught TypeError while rendering: coercing to Unicode: need string or buffer, NoneType found It happens in admin when I try to add or modify on one of my models (display works fine) This…
Armance
  • 5,350
  • 14
  • 57
  • 80
58
votes
6 answers

How can I allow django admin to set a field to NULL?

I've set my Model field to null=True, which allows NULL in MySQL, but I can't seem to assign NULL to the field through Django Admin. I've tried also setting blank=True, but that just sets the field to an empty string. Following this didn't work…
Hubro
  • 56,214
  • 69
  • 228
  • 381
58
votes
6 answers

Django: How to get current user in admin forms?

In Django's ModelAdmin, I need to display forms customized according to the permissions a user has. Is there a way of getting the current user object into the form class, so that i can customize the form in its __init__ method? I think saving the…
Bernhard Vallant
  • 49,468
  • 20
  • 120
  • 148
58
votes
3 answers

Custom validation in Django admin

I have a very simple Django app in order to record the lectures given my colleagues.Since it is quite elementary,I am using the Django admin itself. Here is my models.py: #models.py from django.db import models class Lecture(models.Model): …
Amistad
  • 7,100
  • 13
  • 48
  • 75
57
votes
1 answer

How to set another Inline title in Django Admin?

I need to change the inline title to something else other than the verbose_name of the class Meta in the model. Is there an attribute to achieve this?
eos87
  • 8,961
  • 12
  • 49
  • 77
56
votes
11 answers

How to change the Django admin filter to use a dropdown instead of list?

If, for a field that you want to filter by, you have more than ~10 values, the filtering sidebar starts to be ugly and harder to use. I'm looking for a solution to replace the
  • with a dropdown selection (combobox) or something similar that will…
  • sorin
    • 161,544
    • 178
    • 535
    • 806