Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 350475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T11:33:13+00:00 2026-05-12T11:33:13+00:00

I recently extended with UserProfile so my admin.py looks like this: from django.contrib import

  • 0

I recently extended with UserProfile so my admin.py looks like this:

from django.contrib import admin
from django.contrib.auth.models import User
from models import UserProfile
from django.contrib.auth.admin import UserAdmin

admin.site.unregister(User)

class UserProfileInline(admin.StackedInline):
                model = UserProfile

class UserProfileAdmin(UserAdmin):
#               fieldsets = [
#                       (None,  {'fields': ['image']}),
#                       ('Avatar', {'fields': ['text'], 'classes': ['collapse']}),
#               ]
                inlines = (UserProfileInline,)

admin.site.register(User, UserProfileAdmin)

and models.py like this:

from django.db import models
from django.contrib.auth.models import User

class UserProfile(models.Model):
        # Required
        user = models.ForeignKey(User, unique=True)
        image = models.ImageField(upload_to='media/users/', blank=True, help_text="Your face")
        text = models.TextField(blank=True, help_text="Write something about yourself")

In an app called users that is referred to by settings.py with:

    AUTH_PROFILE_MODULE = users.UserProfile

1

Basically what I want to achieve is to get rid of the #1 StackedInLine
that shows in the admin. The reason I use StackedInLine instead of
TabularInLine is because otherwise I get a “Delete?” column to the
right and I find it optional so I would like to either exclude that or
get rid of the #1 numbering in StackedInLine.

2

Also. I wonder why I cannot use fieldsets when I have loaded the
UserProfile models.py file in admin.py. It simply says the field
doesn’t exist. Do I have to call the fields differently than in django/
contrib/auth/admin.py where I’ve seen it work?

If you feel like there is a more efficient way of doing this just tell me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T11:33:14+00:00Added an answer on May 12, 2026 at 11:33 am

    1

    I think you’re getting too picky here. If you absolutely need control over such minute details you should create your own views instead of using the admin. Otherwise stacked is what you want because tabular doesn’t make much sense for one-to-one relations.

    2

    I’ve been able to use fieldsets in user profiles. The only difference between my code and yours seems to be that I’m using tuple’s instead of dict’s. Here’s mine for comparison:

    class UserProfileInline(admin.StackedInline):
        model = UserProfile
    
    class MyUserAdmin(UserAdmin):
        inlines = [UserProfileInline]
        fieldsets = (
            (None, {'fields': ('username', 'password')}),
            (_('Personal info'), {'fields': ('first_name', 'last_name', 'email')}),
            (_('Permissions'), {'fields': ('is_staff', 'is_active', 'is_superuser')}),
            (_('Important dates'), {'fields': ('last_login', 'date_joined')}),
            (_('Groups'), {'fields': ('groups',)}),
        )
        exclude = ['user_permissions']
    

    EDIT:

    I just did a quick check and the “#1” is coming from the admin template.

    This means you can easily remove it by overriding the stock admin template, although this will affect all your inlines including ones that are one-to-many.

    The stacked inline template can be found in django/contrib/admin/templates/admin/edit_inline/stacked.html

    This means you can copy the template to your own templates directory as templates/admin/edit_inline/stacked.html and this will be loaded by Django at run time instead of the stock template.

    After copying edit your local copy to remove #{{ forloop.counter }} on line 9.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.