Skip to content

Django: Remove default entries from admin menu

The Django administration site comes with a couple of default entries, depending on which apps and middleware is installed.

Usually there is at least "Users" and "Groups", and if the quite common "allauth" is installed, then there is also "Site", "SocialApp", "SocialAccount", and "SocialToken". They are not always necessary, especially when no Social Login is used. Or why have the "Site" administration when only Site=1 is used?

With a few tricks these can be removed from the admin menu.

 

Continue reading "Django: Remove default entries from admin menu"
  • Twitter
  • Bookmark Django: Remove default entries from admin menu at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Django: Remove default entries from admin menu
  • Bloglines Django: Remove default entries from admin menu
  • Technorati Django: Remove default entries from admin menu
  • Fark this: Django: Remove default entries from admin menu
  • Bookmark Django: Remove default entries from admin menu at YahooMyWeb
  • Bookmark Django: Remove default entries from admin menu at Furl.net
  • Bookmark Django: Remove default entries from admin menu at reddit.com
  • Bookmark Django: Remove default entries from admin menu at blinklist.com
  • Bookmark Django: Remove default entries from admin menu at Spurl.net
  • Bookmark Django: Remove default entries from admin menu at Simpy.com
  • Bookmark Django: Remove default entries from admin menu at blogmarks
  • Bookmark Django: Remove default entries from admin menu with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca

Django: disable inline option to add new referenced objects

The Django Web Framework makes it quite easy to add new referenced objects in the admin menu.

Let's say the model has two foreign keys in it:

class TeamMember(models.Model):
    team = models.ForeignKey(Team, on_delete=models.CASCADE, verbose_name=_("Team"))
    user = models.ForeignKey(CustomUser, on_delete=models.CASCADE, verbose_name=_("User"))

And the admin form:

class TeamMemberForm(forms.ModelForm):
    class Meta:
        model = TeamMember

class CustomTeamMemberAdmin(admin.ModelAdmin):
    form = TeamMemberForm
    add_form = TeamMemberForm
    model = TeamMember
    fieldsets = [
        (None,      {'fields': ['team', 'user']}),
    ]

admin.site.register(TeamMember, CustomTeamMemberAdmin)

Then Django will show small a small green "Django add reference" sign next to the fields:

Continue reading "Django: disable inline option to add new referenced objects"
  • Twitter
  • Bookmark Django: disable inline option to add new referenced objects at del.icio.us
  • Facebook
  • Google Bookmarks
  • FriendFeed
  • Digg Django: disable inline option to add new referenced objects
  • Bloglines Django: disable inline option to add new referenced objects
  • Technorati Django: disable inline option to add new referenced objects
  • Fark this: Django: disable inline option to add new referenced objects
  • Bookmark Django: disable inline option to add new referenced objects at YahooMyWeb
  • Bookmark Django: disable inline option to add new referenced objects at Furl.net
  • Bookmark Django: disable inline option to add new referenced objects at reddit.com
  • Bookmark Django: disable inline option to add new referenced objects at blinklist.com
  • Bookmark Django: disable inline option to add new referenced objects at Spurl.net
  • Bookmark Django: disable inline option to add new referenced objects at Simpy.com
  • Bookmark Django: disable inline option to add new referenced objects at blogmarks
  • Bookmark Django: disable inline option to add new referenced objects with wists
  • wong it!
  • Bookmark using any bookmark manager!
  • Stumble It!
  • Identi.ca