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 8527785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:39:13+00:00 2026-06-11T08:39:13+00:00

During the 1st HTTP GET (right after the WSGI in daemon mode is reloaded),

  • 0

During the 1st HTTP GET (right after the WSGI in daemon mode is reloaded), admin.site.unregister throws a NotRegistered exception, but admin.site.register throws an AlreadyRegistered exception (catch-22?) However, on the subsequent HTTP GETs, everything loads just fine with no error.

Setup:

  • Django 1.3
  • Apache 2.2
  • CentOS

settings.py:

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    #'django.contrib.sites', #(this didn't seem to make a difference)
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    'django.contrib.admindocs',
    'base',
    'sample',
    'reports',
    'south',
)

models.py:

from django.db import models
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin as AuthUserAdmin

class Company(models.Model):
  name = models.CharField(max_length=256)

class CompanyUser(models.Model):
  company = models.ForeignKey(Company)
  user = models.OneToOneField(User)

class CompanyUserInline(admin.StackedInline):
  model = CompanyUser
  max_num = 1
  can_delete = False

class CompanyUserAdmin(AuthUserAdmin):
  inlines = [ CompanyUserInline ]

# STUCK HERE !!
try:
  admin.site.unregister(User)
  # throws NotRegistered at / The model User is not registered
except:
  admin.site.register(User, CompanyUserAdmin)
  # throws AlreadyRegistered at / The model User is already registered
  • 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-06-11T08:39:15+00:00Added an answer on June 11, 2026 at 8:39 am

    I found the answer from mlavin on freenode’s #django

    you are defining this in your models.py rather than admin.py (which is
    fine) but if you have any place in your code which does import * on
    that models file it will execute the register calls again

    Moving what belongs in admin.py to admin.py (from models.py) solved it! In my defense though, I inherited the code base – I’m not sure why I would put this snippet in models.py instead of admin.py.

    Interesting to note: while this problem never cropped up locally for me via “manage.py runserver” but only when I deployed via Apache + WSGI, one other person mentioned they were able to reproduce it locally. Weird.

    But case closed.

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

Sidebar

Related Questions

During the development I experience unhandled exceptions at random occasions, but mostly after closing
There is a Silverlight (4.0) application that is calling to WCF-service. During 1st call
during the prepareForSegue I try to assign a value to property and get the
I have 2 windows forms. The 1st one who gets active during start of
After the 1st call to LoadData() the event onLoadResource fires as it should and
What's the proper way to manage persisted entities in the 1st level cache during
During a AuthnRequest, is there a case where the AudienceRestriction <saml:AudienceRestriction> <saml:Audience>http://serviceprovider.com/</saml:Audience> </saml:AudienceRestriction> would
During the installation of my app, I want to create a PostgreSQL-Database and some
During compilation process many errors are thrown on the screen. To start resolving them
During our efforts to design InApp Billing for our Android App, we came up

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.