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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:55:24+00:00 2026-05-30T23:55:24+00:00

I am getting this error in my development environment. I have spent far too

  • 0

I am getting this error in my development environment. I have spent far too long trying to figure this out, especially because I imagine it’s staring me in the face. I created a new ModelForm against one of my models and then started getting this error. It goes away if I comment out the “admin.site.register(ModelName)” lines in my models.py file, but then I can’t inspect the data in the admin site anymore…

Here’s the error:

Environment:


Request Method: GET
Request URL: http://127.0.0.1:8000/admin/

Django Version: 1.3.1
Python Version: 2.7.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'azcerts.certmanager']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.middleware.csrf.CsrfResponseMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
  101.                             request.path_info)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in resolve
  250.             for pattern in self.url_patterns:
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in _get_url_patterns
  279.         patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in _get_urlconf_module
  274.             self._urlconf_module = import_module(self.urlconf_name)
File "C:\Python27\lib\site-packages\django\utils\importlib.py" in import_module
  35.     __import__(name)
File "C:\Users\ntagg\Code\azcerts\urls.py" in <module>
  3. from certmanager.views import addone
File "C:\Users\ntagg\Code\azcerts\certmanager\views.py" in <module>
  4. from forms import CertForm
File "C:\Users\ntagg\Code\azcerts\forms.py" in <module>
  4. from certmanager.models import UserProfile, Cert
File "C:\Users\ntagg\Code\azcerts\certmanager\models.py" in <module>
  52. admin.site.register(UserProfile)
File "C:\Python27\lib\site-packages\django\contrib\admin\sites.py" in register
  85.                 raise AlreadyRegistered('The model %s is already registered' % model.__name__)

Exception Type: AlreadyRegistered at /admin/
Exception Value: The model UserProfile is already registered

Here’s the models.py:

#models.py
from django.db import models
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.localflavor.us.models import USStateField

class Cert(models.Model):
    # My fields are here...

    def __unicode__(self):
        return self.fieldname

class UserProfile(models.Model):
    # My fields are here...

    def __unicode__(self):
        return self.fieldname

admin.site.register(UserProfile)
admin.site.register(Cert)
  • 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-30T23:55:25+00:00Added an answer on May 30, 2026 at 11:55 pm

    Don’t register your models in your models.py, create an admin.py for your app, and do it there.

    # admin.py
    from django.contrib import admin
    from myapp.models import Cert, UserProfile 
    admin.site.register(Cert)
    admin.site.register(UserProfile)
    

    Explanation:

    When you created your model form, Django was importing your models.py twice: once with the path azcerts.certmanager.models (as it is in your INSTALLED_APPS) and again with the path certmanager.models (in the module where you define the model form). The second time Django imported models.py, it tried to register the models again, and gave the error.

    By moving the register commands into admin.py, you ensure that the models will only be registered once.

    It’s a bit messy that models.py can be imported on two different paths like this. The default project layout has changed in Django 1.4, which will prevent gotchas like this.

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

Sidebar

Related Questions

I'm getting this error when running the development environment through RubyMine 3.1. The mysql
I'm Getting this error in my development log while uploadify is uploading the file
I´m getting this error while trying to commit to a svn repository: svn: MKACTIVITY
Keep getting this error after inserting a subdatasheet into a query and trying to
I am getting this error when trying to run internet information services on a
I don't have this problem on my local development environment, but I just deployed
I am new to Android and trying to setup Android Development Environment. I have
I am getting this error in rails whenever i am trying to create an
Getting this error: 2009-09-03 12:44:02.307 xcodebuild[307:10b] warning: compiler 'com.apple.compilers.llvm.clang.1_0.analyzer' is based on missing compiler
Getting this error with jquery & jquery.form. Site has been live for awhile..upgraded to

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.