How to Fix django.contrib.admin.sites.AlreadyRegistered?
This post is focused on how to fix django.contrib.admin.sites.alreadyregistered. this example will help you how to solve django.contrib.admin.sites.alreadyregistered. you'll learn django.contrib.admin.sites.alreadyregistered. step by step explain django.contrib.admin.sites.alreadyregistered solve error example. Alright, let’s dive into the steps.
For in this example, The django.contrib.admin.sites.AlreadyRegisteredissue appears when you're trying to register a model that is already registered in the app.
let's see bellow example here we'll see an example of the issue and how to solve it.
Facing Issue Like This:
in this below example code you have we've registered the Blog model for two times then you will get error.admin.py
from django.contrib import admin from .models import * # Register your models here. admin.site.register(Blog) admin.site.register(Blog)Output
django.contrib.admin.sites.AlreadyRegistered: The model Blog is already registered in app 'core'.
So, how to solve issue we need to remove the duplicate line.admin.py
from django.contrib import admin from .models import * # Register your models here. admin.site.register(Blog)Output
System check identified no issues (0 silenced). Sep 14, 2022 - 00:33:31 Django version 3.2.1, using settings 'app.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
I Hope It will help you....
Happy Django Coding!