Muestra las diferencias entre dos versiones de la página.
| Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
|
wiki2:python:medium_django [2018/11/09 10:21] alfred [Cómo tener varios setting files] |
wiki2:python:medium_django [2020/05/09 09:25] (actual) |
||
|---|---|---|---|
| Línea 139: | Línea 139: | ||
| Namespaced URLs are specified using the ':' operator. For example, the main index page of the admin application is referenced using 'admin:index'. This indicates a namespace of 'admin', and a named URL of 'index'. Namespaces can also be nested. The named URL 'sports:polls:index' would look for a pattern named 'index' in the namespace 'polls' that is itself defined within the top-level namespace 'sports'. | Namespaced URLs are specified using the ':' operator. For example, the main index page of the admin application is referenced using 'admin:index'. This indicates a namespace of 'admin', and a named URL of 'index'. Namespaces can also be nested. The named URL 'sports:polls:index' would look for a pattern named 'index' in the namespace 'polls' that is itself defined within the top-level namespace 'sports'. | ||
| + | |||
| + | ==== Dynamic fields ==== | ||
| + | For example in urls: | ||
| + | <code> | ||
| + | urlpatterns = [ | ||
| + | path('', TemplateView.as_view( | ||
| + | template_name="fok/home.html", | ||
| + | extra_context={ | ||
| + | # The lambda makes this expression to be executed each call of home (because of the admin updates) | ||
| + | 'campaigns': lambda: Campaign.objects.filter(visible=True).order_by('-created_at') | ||
| + | } | ||
| + | ), name='home'), | ||
| + | ... | ||
| + | </code> | ||
| ===== Questions ===== | ===== Questions ===== | ||