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

from mezzanine.accounts.models import get_profile_model


Profile = get_profile_model()


class ProfileInline(admin.StackedInline):
    model = Profile
    can_delete = False
    template = "admin/profile_inline.html"
    extra = 0


class UserProfileAdmin(UserAdmin):
    inlines = (ProfileInline,) if Profile else ()


admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)


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

from mezzanine.accounts.models import get_profile_model
from mezzanine.core.admin import AdminProfileInline


Profile = get_profile_model()


class ProfileInline(admin.StackedInline):
    model = Profile
    can_delete = False
    template = "admin/profile_inline.html"
    extra = 0


class UserProfileAdmin(UserAdmin):
    inlines = (ProfileInline, AdminProfileInline) if Profile else (AdminProfileInline,)


admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)

Include AdminProfileInline so that it is not lost if the user enables Mezzanine accounts.
Include AdminProfileInline so that it is not lost if the user enables Mezzanine accounts.

--HG--
branch : admin_site_permissions

  
  from django.contrib import admin
  from django.contrib.auth.admin import UserAdmin
  from django.contrib.auth.models import User
  
  from mezzanine.accounts.models import get_profile_model
+ from mezzanine.core.admin import AdminProfileInline
  
  
  Profile = get_profile_model()
  
  
  class ProfileInline(admin.StackedInline):
      model = Profile
      can_delete = False
      template = "admin/profile_inline.html"
      extra = 0
  
  
  class UserProfileAdmin(UserAdmin):
-     inlines = (ProfileInline,) if Profile else ()
+     inlines = (ProfileInline, AdminProfileInline) if Profile else (AdminProfileInline,)
  
  
  admin.site.unregister(User)
  admin.site.register(User, UserProfileAdmin)
  
Include AdminProfileInline so that it is not lost if the user enables Mezzanine accounts.
## Code Before:

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

from mezzanine.accounts.models import get_profile_model


Profile = get_profile_model()


class ProfileInline(admin.StackedInline):
    model = Profile
    can_delete = False
    template = "admin/profile_inline.html"
    extra = 0


class UserProfileAdmin(UserAdmin):
    inlines = (ProfileInline,) if Profile else ()


admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)

## Instruction:
Include AdminProfileInline so that it is not lost if the user enables Mezzanine accounts.
## Code After:

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

from mezzanine.accounts.models import get_profile_model
from mezzanine.core.admin import AdminProfileInline


Profile = get_profile_model()


class ProfileInline(admin.StackedInline):
    model = Profile
    can_delete = False
    template = "admin/profile_inline.html"
    extra = 0


class UserProfileAdmin(UserAdmin):
    inlines = (ProfileInline, AdminProfileInline) if Profile else (AdminProfileInline,)


admin.site.unregister(User)
admin.site.register(User, UserProfileAdmin)
