How do I create sub-applications in Django?

后端 未结 5 886
后悔当初
后悔当初 2020-12-08 02:17

I\'m a Django newbie, but fairly experienced at programming. I have a set of related applications that I\'d like to group into a sub-application but can not figure out how t

相关标签:
5条回答
  • 2020-12-08 02:17

    Go to your apps folder. Try:

    python ../manage.py startapp app_name
    
    0 讨论(0)
  • 2020-12-08 02:24

    According to Django documentation,

    If the optional destination is provided, Django will use that existing directory rather than creating a new one. You can use ‘.’ to denote the current working directory.

    For example:

    django-admin startapp myapp /Users/jezdez/Code/myapp

    So, you can do it by this method:

    1. Create sub_app1 directory in app directory
    2. python manage.py startapp sub_app1 app/sub_app1
    0 讨论(0)
  • 2020-12-08 02:25
    django-admin.py startapp myapp /Users/jezdez/Code/myapp
    

    Reference: Django Admin documentation

    0 讨论(0)
  • 2020-12-08 02:36

    You can still do this :

    cd app
    django-admin startapp subapp1
    

    This will work (create the application basic structure), however app and subapp1 will still be considered as two unrelated applications in the sense that you have to add both of them to INSTALLED_APPS in your settings.

    Does this answer your question ? Otherwise you should tell more about what you are trying to do.

    0 讨论(0)
  • 2020-12-08 02:40

    Django doesn't support "subapplications" per se. If you want code to be collected in packages within an app then just create them yourself. Otherwise you're just asking for pain.

    0 讨论(0)
提交回复
热议问题