Updated documentation on packaging patterns
This commit is contained in:
parent
6e3dd9b3ce
commit
c62422c318
1 changed files with 16 additions and 0 deletions
|
|
@ -212,6 +212,7 @@ static files and templates. Imagine you have an application like this::
|
||||||
/yourapplication
|
/yourapplication
|
||||||
__init__.py
|
__init__.py
|
||||||
/apps
|
/apps
|
||||||
|
__init__.py
|
||||||
/frontend
|
/frontend
|
||||||
__init__.py
|
__init__.py
|
||||||
views.py
|
views.py
|
||||||
|
|
@ -244,6 +245,21 @@ name of the module. So for the admin it would be
|
||||||
possible to refer to templates without the prefixed module name. This is
|
possible to refer to templates without the prefixed module name. This is
|
||||||
explicit unlike URL rules.
|
explicit unlike URL rules.
|
||||||
|
|
||||||
|
You also need to explicitly pass the ``url_prefix`` argument when
|
||||||
|
registering your modules this way::
|
||||||
|
|
||||||
|
# in yourapplication/__init__.py
|
||||||
|
from flask import Flask
|
||||||
|
from yourapplication.apps.admin.views import admin
|
||||||
|
from yourapplication.apps.frontend.views import frontend
|
||||||
|
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.register_module(admin, url_prefix='/admin')
|
||||||
|
app.register_module(frontend, url_prefix='/frontend')
|
||||||
|
|
||||||
|
This is because Flask cannot infer the prefix from the package names.
|
||||||
|
|
||||||
.. admonition:: References to Static Folders
|
.. admonition:: References to Static Folders
|
||||||
|
|
||||||
Please keep in mind that if you are using unqualified endpoints by
|
Please keep in mind that if you are using unqualified endpoints by
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue