How do “apps” work from django's point of view?
up vote
1
down vote
favorite
First of all, the question is technical, not conceptual.
The docs mention, in various places, that you are supposed to put in INSTALLED_APPS
the root module of your app. However, what is that module supposed to contain?
Most of the files created by startapp myapp
are just there by convention. For example urls, views, admin
files are imported from other modules by fully qualified name, and could really be anywhere, so they are just conventions. The only thing that seems to be "hard-coded" in the django logic is the models.py
.
So, from the INSTALLED_APPS
point of view, does an app consist solely of its models.py
? Or is there something else I'm missing? And does the documentation explicitly state this anywhere?
python django
add a comment |
up vote
1
down vote
favorite
First of all, the question is technical, not conceptual.
The docs mention, in various places, that you are supposed to put in INSTALLED_APPS
the root module of your app. However, what is that module supposed to contain?
Most of the files created by startapp myapp
are just there by convention. For example urls, views, admin
files are imported from other modules by fully qualified name, and could really be anywhere, so they are just conventions. The only thing that seems to be "hard-coded" in the django logic is the models.py
.
So, from the INSTALLED_APPS
point of view, does an app consist solely of its models.py
? Or is there something else I'm missing? And does the documentation explicitly state this anywhere?
python django
1
I'm no expert in the Django internals, but does this page have the information you want? docs.djangoproject.com/en/2.1/ref/applications. In particular:It is important to understand that a Django application is just a set of code that interacts with various parts of the framework. There’s no such thing as an Application object. However, there’s a few places where Django needs to interact with installed applications, mainly for configuration and also for introspection. That’s why the application registry maintains metadata in an AppConfig instance for each installed application.
– Robin Zigmond
Nov 9 at 15:12
@RobinZigmond: thanks. the problem is what exactly configuration and retrospection includes. I can't find it anywhere in the docs. The sentence following, seems to enforce my suspicions that only models matter:There’s no restriction that a project package can’t also be considered an application and have models, etc. (which would require adding it to INSTALLED_APPS).
– blue_note
Nov 9 at 15:21
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
First of all, the question is technical, not conceptual.
The docs mention, in various places, that you are supposed to put in INSTALLED_APPS
the root module of your app. However, what is that module supposed to contain?
Most of the files created by startapp myapp
are just there by convention. For example urls, views, admin
files are imported from other modules by fully qualified name, and could really be anywhere, so they are just conventions. The only thing that seems to be "hard-coded" in the django logic is the models.py
.
So, from the INSTALLED_APPS
point of view, does an app consist solely of its models.py
? Or is there something else I'm missing? And does the documentation explicitly state this anywhere?
python django
First of all, the question is technical, not conceptual.
The docs mention, in various places, that you are supposed to put in INSTALLED_APPS
the root module of your app. However, what is that module supposed to contain?
Most of the files created by startapp myapp
are just there by convention. For example urls, views, admin
files are imported from other modules by fully qualified name, and could really be anywhere, so they are just conventions. The only thing that seems to be "hard-coded" in the django logic is the models.py
.
So, from the INSTALLED_APPS
point of view, does an app consist solely of its models.py
? Or is there something else I'm missing? And does the documentation explicitly state this anywhere?
python django
python django
asked Nov 9 at 15:00
blue_note
10.7k31831
10.7k31831
1
I'm no expert in the Django internals, but does this page have the information you want? docs.djangoproject.com/en/2.1/ref/applications. In particular:It is important to understand that a Django application is just a set of code that interacts with various parts of the framework. There’s no such thing as an Application object. However, there’s a few places where Django needs to interact with installed applications, mainly for configuration and also for introspection. That’s why the application registry maintains metadata in an AppConfig instance for each installed application.
– Robin Zigmond
Nov 9 at 15:12
@RobinZigmond: thanks. the problem is what exactly configuration and retrospection includes. I can't find it anywhere in the docs. The sentence following, seems to enforce my suspicions that only models matter:There’s no restriction that a project package can’t also be considered an application and have models, etc. (which would require adding it to INSTALLED_APPS).
– blue_note
Nov 9 at 15:21
add a comment |
1
I'm no expert in the Django internals, but does this page have the information you want? docs.djangoproject.com/en/2.1/ref/applications. In particular:It is important to understand that a Django application is just a set of code that interacts with various parts of the framework. There’s no such thing as an Application object. However, there’s a few places where Django needs to interact with installed applications, mainly for configuration and also for introspection. That’s why the application registry maintains metadata in an AppConfig instance for each installed application.
– Robin Zigmond
Nov 9 at 15:12
@RobinZigmond: thanks. the problem is what exactly configuration and retrospection includes. I can't find it anywhere in the docs. The sentence following, seems to enforce my suspicions that only models matter:There’s no restriction that a project package can’t also be considered an application and have models, etc. (which would require adding it to INSTALLED_APPS).
– blue_note
Nov 9 at 15:21
1
1
I'm no expert in the Django internals, but does this page have the information you want? docs.djangoproject.com/en/2.1/ref/applications. In particular:
It is important to understand that a Django application is just a set of code that interacts with various parts of the framework. There’s no such thing as an Application object. However, there’s a few places where Django needs to interact with installed applications, mainly for configuration and also for introspection. That’s why the application registry maintains metadata in an AppConfig instance for each installed application.
– Robin Zigmond
Nov 9 at 15:12
I'm no expert in the Django internals, but does this page have the information you want? docs.djangoproject.com/en/2.1/ref/applications. In particular:
It is important to understand that a Django application is just a set of code that interacts with various parts of the framework. There’s no such thing as an Application object. However, there’s a few places where Django needs to interact with installed applications, mainly for configuration and also for introspection. That’s why the application registry maintains metadata in an AppConfig instance for each installed application.
– Robin Zigmond
Nov 9 at 15:12
@RobinZigmond: thanks. the problem is what exactly configuration and retrospection includes. I can't find it anywhere in the docs. The sentence following, seems to enforce my suspicions that only models matter:
There’s no restriction that a project package can’t also be considered an application and have models, etc. (which would require adding it to INSTALLED_APPS).
– blue_note
Nov 9 at 15:21
@RobinZigmond: thanks. the problem is what exactly configuration and retrospection includes. I can't find it anywhere in the docs. The sentence following, seems to enforce my suspicions that only models matter:
There’s no restriction that a project package can’t also be considered an application and have models, etc. (which would require adding it to INSTALLED_APPS).
– blue_note
Nov 9 at 15:21
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Thanks to
@RobinZigmond
for pointing me to the correct part of the docs.
It seems that indeed, everything is a convention, with the exception of models
submodule. The description of the initialization process states that for each app in INSTALLED_APPS
- the module
myapp
is imported. models are not ready yet. - the
models
submodule ifmyapp
is imported. you must import of define your models inmodels.py
ormodels/__init__.py
- sets the corresponding
ready
flag toTrue
in the application registry
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Thanks to
@RobinZigmond
for pointing me to the correct part of the docs.
It seems that indeed, everything is a convention, with the exception of models
submodule. The description of the initialization process states that for each app in INSTALLED_APPS
- the module
myapp
is imported. models are not ready yet. - the
models
submodule ifmyapp
is imported. you must import of define your models inmodels.py
ormodels/__init__.py
- sets the corresponding
ready
flag toTrue
in the application registry
add a comment |
up vote
0
down vote
Thanks to
@RobinZigmond
for pointing me to the correct part of the docs.
It seems that indeed, everything is a convention, with the exception of models
submodule. The description of the initialization process states that for each app in INSTALLED_APPS
- the module
myapp
is imported. models are not ready yet. - the
models
submodule ifmyapp
is imported. you must import of define your models inmodels.py
ormodels/__init__.py
- sets the corresponding
ready
flag toTrue
in the application registry
add a comment |
up vote
0
down vote
up vote
0
down vote
Thanks to
@RobinZigmond
for pointing me to the correct part of the docs.
It seems that indeed, everything is a convention, with the exception of models
submodule. The description of the initialization process states that for each app in INSTALLED_APPS
- the module
myapp
is imported. models are not ready yet. - the
models
submodule ifmyapp
is imported. you must import of define your models inmodels.py
ormodels/__init__.py
- sets the corresponding
ready
flag toTrue
in the application registry
Thanks to
@RobinZigmond
for pointing me to the correct part of the docs.
It seems that indeed, everything is a convention, with the exception of models
submodule. The description of the initialization process states that for each app in INSTALLED_APPS
- the module
myapp
is imported. models are not ready yet. - the
models
submodule ifmyapp
is imported. you must import of define your models inmodels.py
ormodels/__init__.py
- sets the corresponding
ready
flag toTrue
in the application registry
answered Nov 9 at 15:44
blue_note
10.7k31831
10.7k31831
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228182%2fhow-do-apps-work-from-djangos-point-of-view%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I'm no expert in the Django internals, but does this page have the information you want? docs.djangoproject.com/en/2.1/ref/applications. In particular:
It is important to understand that a Django application is just a set of code that interacts with various parts of the framework. There’s no such thing as an Application object. However, there’s a few places where Django needs to interact with installed applications, mainly for configuration and also for introspection. That’s why the application registry maintains metadata in an AppConfig instance for each installed application.
– Robin Zigmond
Nov 9 at 15:12
@RobinZigmond: thanks. the problem is what exactly configuration and retrospection includes. I can't find it anywhere in the docs. The sentence following, seems to enforce my suspicions that only models matter:
There’s no restriction that a project package can’t also be considered an application and have models, etc. (which would require adding it to INSTALLED_APPS).
– blue_note
Nov 9 at 15:21