Home > Blockchain >  how to create an app with in app inside a Django project? How that app can be registered to setting
how to create an app with in app inside a Django project? How that app can be registered to setting

Time:10-21

*project- New.app-app want to add an app inside app

1.how to register this to the setting.py file?

  1. what are the things I should be worried once I have an app with in an app?

CodePudding user response:

First create inner app using command

django-admin startapp demoapp

Here i created Two apps first at Project Directory & second one is in app directory

├───demo
│   └───__pycache__
├───myapp  <-------- this is primary app
│   ├───demoapp <-------- this inner app
│   │   ├───migrations
│   │   │   └───__pycache__
│   │   ├───templates
│   │   └───__pycache__
│   ├───migrations
│   │   └───__pycache__
│   ├───templates
│   └───__pycache__
└───static

Now do settings in settins.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'myapp', <-------- this is primary app
    'myapp.demoapp', <-------- this inner app
]

Now do settings in (demoapp > apps.py)

from django.apps import AppConfig


class DemoappConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'myapp.demoapp'

CodePudding user response:

To create an app in Django do this:

First, navigate to project folder in terminal or cmd and run above command:

python manage.py startapp appname #This will create an app inside Django project

Second, after create app:

In settings.py file:

add your app in INSTALLED_APP: ex:

INSTALLED_APPs = [
   'appname',
]

This is the only thing you have to do after create app.

  • Related