Configurazione

urls.py

in urls.py devono essere avviati i vari autodiscover:

dajaxice_autodiscover()
autocomplete_light.autodiscover()
admin.autodiscover()
admin_tools.dashboard.autodiscover()

in aggiunta devono essere aggiunti i pattern per la localizzazione. jmb-start dovrebbe fare questo in automatico.

Monkey Patch

Jumbo relies on some patches to the official django version that can be applied using the function jmb.core.monkey.patch() in urls.py:

from jmb.core import monkey
monkey.patch()
jmb.core.monkey.patch(exclude=None)[source]

Apply all patches Jumbo relyes on. Currently management commands, jquery, and timepicker

Parameters:exclude – a list of strings naming the patches that will not be applied. ‘jquery’ patch will only be applied if cms is in INSTALLED_APPS

management commands

Django find_management_module fails at finding modules when namespaces are used.

This version of find_management_module tries a real import when django fails to find the module. The difference is that django only uses:

imp.find_module(...)

that doesn’t implement full module search algorithm. We’re going to place this code in urls.py:

from jmb.core import monkey
monkey.fix_find_namespaces()

At the moment there’s an open ticket

Django and jQuery

jmb.core.monkey.conf.patch_cms_page_not_to_overwrite_jquery()[source]

MonkeyPatch django-cms not to overwrite jquery.

While django make attention to use djangojQuery and not to overwite standard $(), so different versions can coexist, PageAdmin and PluginEditor overwrite it with django.jQuery. Utilizzata in urls.py cosi:

from jmb.core import monkey

if settings.CMS_ENABLED:
    urlpatterns += patterns('',
        url(r'^', include('cms.urls')),
    )
    monkey.patch_cms_page_not_to_overwrite_jquery()

timepicker

Datetime and time widgets in Django are pretty poor ones.

Html widgets used by admin are defined in django.contrib.admin.options in a dict named FORMFIELD_FOR_DBFIELD_DEFAULTS.

We overwrite it in jmb.core.admin.options and define a widget that is derived from jQuery.ui‘s default one.

Previous topic

Django: aggiunte e standardizzazioni

Next topic

Middlewares

This Page