Django Development Notes – 1
I was reading about this about setting up Jenkins with Rails for Continous Integration, and it crossed my mind, thing will be great if I set a Jenkins server to doing some automated task for a Django project. I proposed this to our solution architect, and he suggests me to try thing first, before make an adjustment to our current development workflow. And the journey began…
At the moment, I am developing a personal django web application, a project bug tracking software, specially tailored for my needs. It use PostgreSQL database, because I just hate SQLite and MySQL (no offense though). In python you use psycopg2 for connecting to PostgreSQL database.
I googled about django and Jenkins integration, and I found django-jenkins, and I found it is supposed to be easy. All you need is to install django-jenkins packages using pip
pip install django-jenkins
then add django_jenkins into your INSTALLED_APPS in your settings.py file. Lastly, run the task for Jenkins, by issuing this command:
python manage.py jenkins
When I ran that command, I got this error:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/core/management/base.py", line 220, in execute
output = self.handle(*args, **options)
File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django_jenkins/management/commands/__init__.py", line 70, in handle
if test_runner.run_tests(test_labels):
File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django_jenkins/runner.py", line 339, in run_tests
self.teardown_databases(old_config)
File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/test/simple.py", line 327, in teardown_databases
connection.creation.destroy_test_db(old_name, self.verbosity)
File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/db/backends/creation.py", line 461, in destroy_test_db
self._destroy_test_db(test_database_name, verbosity)
File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/db/backends/creation.py", line 470, in _destroy_test_db
self.set_autocommit()
File "/Users/rakhmad/.pythonbrew/venvs/Python-2.7.2/continuum/lib/python2.7/site-packages/django/db/backends/creation.py", line 481, in set_autocommit
self.connection.connection.autocommit = True
psycopg2.ProgrammingError: autocommit cannot be used inside a transaction
WFT is this error? After doing some googling, I found that Django’s test suite is incompatible with psycopg2 newer than 2.4.1. This issues has been around about 9 months and still no fix from Django. The only fix I found is to install psycopg2 2.4.1 version. You can do that by doing this:
pip uninstall psycopg2 # answer by typing ‘y’
pip install psycopg2==2.4.1
No trackbacks yet.