Fixed a terrible wrong part in the module documentation
This commit is contained in:
parent
6562f2e152
commit
8ed051d5b5
1 changed files with 10 additions and 7 deletions
|
|
@ -248,22 +248,25 @@ If you want to refer to the templates you just have to prefix it with the
|
||||||
name of the module. So for the admin it would be
|
name of the module. So for the admin it would be
|
||||||
``render_template('admin/list_items.html')`` and so on. It is not
|
``render_template('admin/list_items.html')`` and so on. It is not
|
||||||
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. Also with the move of the views into from
|
||||||
|
`yourapplication.views.admin` too `yourapplication.apps.admin.views` you
|
||||||
|
will have to give the module an explit shortname. Why? Because otherwise
|
||||||
|
all your modules will be internally known as `views` which is obviously
|
||||||
|
not what you want::
|
||||||
|
|
||||||
You also need to explicitly pass the ``url_prefix`` argument when
|
# in yourapplication/apps/admin/views.py
|
||||||
registering your modules this way::
|
admin = Module(__name__, 'admin')
|
||||||
|
|
||||||
|
The setup code changes slightly because of the imports::
|
||||||
|
|
||||||
# in yourapplication/__init__.py
|
# in yourapplication/__init__.py
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from yourapplication.apps.admin.views import admin
|
from yourapplication.apps.admin.views import admin
|
||||||
from yourapplication.apps.frontend.views import frontend
|
from yourapplication.apps.frontend.views import frontend
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.register_module(admin, url_prefix='/admin')
|
app.register_module(admin, url_prefix='/admin')
|
||||||
app.register_module(frontend, url_prefix='/frontend')
|
app.register_module(frontend)
|
||||||
|
|
||||||
This is because Flask cannot infer the prefix from the package names.
|
|
||||||
|
|
||||||
.. admonition:: References to Static Folders
|
.. admonition:: References to Static Folders
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue