Skip to content

Commit c62422c

Browse files
agentultramitsuhiko
authored andcommitted
Updated documentation on packaging patterns
1 parent 6e3dd9b commit c62422c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/patterns/packages.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ static files and templates. Imagine you have an application like this::
212212
/yourapplication
213213
__init__.py
214214
/apps
215+
__init__.py
215216
/frontend
216217
__init__.py
217218
views.py
@@ -244,6 +245,21 @@ name of the module. So for the admin it would be
244245
possible to refer to templates without the prefixed module name. This is
245246
explicit unlike URL rules.
246247

248+
You also need to explicitly pass the ``url_prefix`` argument when
249+
registering your modules this way::
250+
251+
# in yourapplication/__init__.py
252+
from flask import Flask
253+
from yourapplication.apps.admin.views import admin
254+
from yourapplication.apps.frontend.views import frontend
255+
256+
257+
app = Flask(__name__)
258+
app.register_module(admin, url_prefix='/admin')
259+
app.register_module(frontend, url_prefix='/frontend')
260+
261+
This is because Flask cannot infer the prefix from the package names.
262+
247263
.. admonition:: References to Static Folders
248264

249265
Please keep in mind that if you are using unqualified endpoints by

0 commit comments

Comments
 (0)