Author: adiyatmubarak

Fix Django-Jet Select Dropdown not Working on Custom Page

I’m having an issue when creating a custom page in django-jet. I’m using v1.0.6 and always got jQuery error in dropdown select in my custom page.

Uncaught TypeError: django.jQuery is not a function
at HTMLSelectElement.<anonymous> (bundle.min.js?v=1.0.8:1)
at HTMLSelectElement.dispatch (bundle.min.js?v=1.0.8:9)
at HTMLSelectElement.m.handle (bundle.min.js?v=1.0.8:9)
at Object.trigger (bundle.min.js?v=1.0.8:9)
at HTMLSelectElement.<anonymous> (bundle.min.js?v=1.0.8:9)
at Function.each (bundle.min.js?v=1.0.8:8)
at ot.fn.init.each (bundle.min.js?v=1.0.8:7)
at ot.fn.init.trigger (bundle.min.js?v=1.0.8:9)
at (bundle.min.js?v=1.0.8:12)
at o.<anonymous> (bundle.min.js?v=1.0.8:12)

I solved my issue by adding jquery manually following below in my custom page.

{% block extrahead %}
{{ block.super }}

{% endblock %}

Hope this issue fixed in next release.



Running Specific Test in django-nose

Since I used django-nose for my project. Django-nose runner cannot behave like default django test runner.

Following command will not work in django-nose test runner.

# Run all the tests found within the 'animals' package
$ ./ test appname

# Run just one test case
$ ./ test appname.tests.TestCaseName

# Run just one test method
$ ./ test appname.tests.TestCaseName.test_function_name

Because django-nose structured all the test in one package called tests following below.


Here is the alternative to run specific task in django-nose.

# Run all the tests found within the 'animals' package
$ ./ test appname

# Run just one test case
$ ./ test appname.tests.test_script:TestCaseName

# Run just one test method
$ ./ test appname.tests.test_script:TestCaseName.test_function_name


Exclude folders and line of codes from Test Coverage

Here is my coverage setup in my project. I excluded some folders and line of codes that not important in my testing.

I put these config in .coveragerc

omit =

exclude_lines =
    def __unicode__
    if setttings.TESTING
    def __repr__
    def __str__

Disable django-haystack During Testing

I use django-haystack and elasticsearch for the search engine in our apps. But I don’t want my model that registered to haystack do indexing during the testing. I avoid haystack indexing by adding these following lines of code below in my

import sys

TESTING = 'test' in sys.argv
    HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.BaseSignalProcessor'
    HAYSTACK_CONNECTIONS['default'] = {
        'ENGINE': 'haystack.backends.simple_backend.SimpleEngine',