Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove default apps in INSTALLED_APPS

I'm new to Django and python in general and i'm trying to set up a RESTful api using Django and Django Rest Framework, so my problem is that i want to get rid of the default installed apps, something like this:

INSTALLED_APPS = [
    #'django.contrib.admin',
    #'django.contrib.auth',
    #'django.contrib.contenttypes',
    #'django.contrib.sessions',
    #'django.contrib.messages',
    #'django.contrib.staticfiles',
    'rest_framework',
    'myapp',
]

since i want a simple api (with no UI) that provides me with some data. But when i run python manage.py makemigrations i get the following error:

LookupError: No installed app with label 'admin'

does this mean these apps are essential?

Thanks in advance.

like image 936
mohamedSdn Avatar asked Oct 18 '25 18:10

mohamedSdn


1 Answers

Keep in mind that Django Rest Framework inherit a lot from Django, and if you are using other packages they likely do the same too; you are free to remove some apps (e.g. django.contrib.sessions if you your are not going to use them) but it depends on what you are going to do in your project.

In particular the error you are referring to is caused by the removal of django.contrib.admin which provides the admin interface for your project, very useful in the development phase. You can read more about it here. If you have created your app with the standard django-admin startproject and django-admin startapp by default you are importing the admin app form urls.py and admin.py files with this line of code:

from django.contrib import admin

Just get rid of it (and the consequent code in admin.py and urls.py which is referring to the admin app) and the error should go away.

Each application has its own purpose. You can learn more about that here:

  1. django.contrib.admin: documentation;
  2. django.contrib.auth: documentation;
  3. django.contrib.contenttypes: documentation;
  4. django.contrib.sessions: documentation;
  5. django.contrib.messages: documentation;
  6. django.contrib.staticfiles: documentation.

Once you understood the purpose of each app and having clear the features of your project and the packages you'll be using you can choose which applications are to be removed; although at least for the beginning, while you are learning, i personally suggest you to simply keep all of them just to be safe, considering that they are providing very basic functionalities.

like image 166
Francesco Pinzauti Avatar answered Oct 20 '25 07:10

Francesco Pinzauti