Note that there are some explanatory texts on larger screens.

plurals
  1. POUserProfile StackedInLine/TabularInLine redesigned
    primarykey
    data
    text
    <p><strong><em>Hello everyone and thanks for reading.</em></strong></p> <p>I have a simple problem that I want to get rid of and I have not seen examples where this is achieved yet although searching around the net for quite a while.</p> <p>I recently extended with UserProfile so my admin.py looks like this:</p> <pre><code>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) </code></pre> <p>and models.py like this:</p> <pre><code>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 </code></pre> <h1>1</h1> <p>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.</p> <p>This is what it looks like in "the real world" .. (Marked with red)</p> <p><strong>Stacked:</strong> hxxp://i28.tinypic.com/2lsadkg.jpg</p> <p><strong>Tabular:</strong> hxxp://i27.tinypic.com/4lybs.jpg</p> <h1>2</h1> <p>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?</p> <p>If you feel like there is a more efficient way of doing this just tell me. I am open for all answers.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload