2

I am using Django 3.2, and Django REST Framework. Main project name is ECOM and api is app. Inside api there are multiple apps like category, migrations, order, payment, product, user. Now I want to inform ecom.settings about installed api. HOW I should do it ?

settings.py of ECOM :

INSTALLED_APPS = [
     #other basic install
    'corsheaders',
    'rest_framework',
    'rest_framework.authtoken',
    'api',
    'api.category',
]

but getting error.

My category apps.py file looks like

class CategoryConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'category'
2
  • What's the error? Jun 22, 2021 at 4:27
  • @AnkitTiwari yes bro problem solved thanks a lot. Jun 22, 2021 at 6:43

3 Answers 3

8

Try to change name in your category apps.py like this

class CategoryConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'api.category'
3

AppConfig.name is a full python path to the application. in your case your app category is inside another app called api so try to change your apps.py file to this :

class CategoryConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'api.category' // full path to your app category

the source from django documentation : https://docs.djangoproject.com/en/4.0/ref/applications/#django.apps.AppConfig.name

0

You will have to make api directory a package by creating a __init__.py file in it. Then instead of adding just api in INSTALLED_APPS list just add api.category.

Like this -

INSTALLED_APPS = [
     #other basic install
    'corsheaders',
    'rest_framework',
    'rest_framework.authtoken',
    'api.category',
]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.