1. Introduction
How can I display some data from the database on the admin page?
Are Groups and Users automatically displayed on the page?
2. admin.py
How can I display tables on the admin site?
In Django, if you want a model’s table (like your ClientDocument) to be visible and manageable in the Django
admin site, you need to register the model in the app’s admin.py file.
Here’s how you do it step by step:
1. Open your app’s admin.py file
For example, if your app is called myapp, open:
2. Import your model
3. Register your model
Basic registration:
This will make the table appear in the admin site with default settings.
4. (Optional) Customize how it looks
If you want more control over how it’s displayed (columns, filters, search), you can use a ModelAdmin class:
5. Make sure the admin site is enabled
In your mysite/urls.py (project’s urls.py), ensure you have:
6. Create a superuser to log in
If you haven’t already:
Then enter username, email, and password.
7. Log in and check
Run the server:
Open http://127.0.0.1:8000/admin/, log in with the superuser credentials, and you should see Client
Documents listed.
If you want, I can show you how to make the ClientDocument table display with the owner’s username and
file link directly in the admin list so it’s more user-friendly.
3. Groups and Users are automatically displayed
I opened my admin site:
https://myid.pythonanywhere.com/admin/
In the Authentication and Authorization, there are Groups and Users. I didn't modify admin.py like admin.site.register(ClientDocument). Are Groups and Users automatically displayed on the admin site?
Yes — exactly!
-
Django automatically registers its built-in User and Group models in the admin site.
-
That’s why you see Groups and Users under “Authentication and Authorization” without doing anything in your app’s
admin.py.
Any model that comes built into Django, like User and Group from django.contrib.auth, is pre-registered so you can manage them right away.
For your custom models (like ClientDocument or ClientProfile), you must register them yourself in your app’s admin.py to make them
appear in the admin.
Example:
After that, ClientDocument will show up in your admin site just like Users and Groups.
Do you want me to show how to make it display nicely with owner username and upload date?
