get_absolute_url() method is cool, but in some cases is not needed. django.contrib.auth.models.User has it set by default, this cause my projects to have a broken link in the admin.
How can I prevent that from happening?
In one of my old projects I set a custom template in which I removed the html of the button, it doesn't sound like a good solution that would scale though. Anything better?
You can add another class called Meta in your model to specify plural display name. For example, if the model's name is Category , the admin displays Categorys , but by adding the Meta class, we can change it to Categories . Literally saved my life!
Django admin allows access to users marked as is_staff=True . To disable a user from being able to access the admin, you should set is_staff=False . This holds true even if the user is a superuser. is_superuser=True .
You can override forms for django's built-in admin by setting form attribute of ModelAdmin to your own form class. See: https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.form.
Django 2.0 above you can add in default admin
admin.site.site_url = None
Above trick worked for me very well.
This can be done, per model, as of django 1.7.
# myapp/admin.py
from django.contrib import admin
from myapp.models import MyModel
class MyModelAdmin(admin.ModelAdmin):
view_on_site = False
admin.site.register(MyModel,MyModelAdmin)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With