Services Blog Français

How to see exception stacktraces with django LiveServerTestCase

| by jpic | django python
After playing with selenium and LiveServerTestCase a little while, you might see this: Traceback (most recent call last): File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run self.result = application(self.environ, self.start_response) File "/home/jpic/env/local/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 68, in __call__ return super(StaticFilesHandler, self).__call__(environ, start_response) File "/home/jpic/env/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__ response = self.get_response(request) File "/home/jpic/env/local/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 63, in get_response return super(StaticFilesHandler, self).get_response(request) File "/home/jpic/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 153, in get_response response = self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "/home/jpic/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 228, in handle_uncaught_exception return callback(request, **param_dict) File "/home/jpic/env/local/lib/python2. Read More

Free services you can use to make a great python app

| by jpic | python
A great django app should have: a source repository an issue tracker documentation release packages a mailing list continuous integration translations Source code repository and issue tracker Usually, source code repository services come with an issue tracker. The most common are Github and Bitbucket for mercurial. You can find other git hosts such as Baregit but they don’t necessarily include an issue tracker like Github or Bitbucket. Most django apps use github, but also many of them are on bitbucket. Read More

Dvorak intl code

| by jpic | dvorak-intl-code
After upgrading Ubuntu, I had to redo my custom dvorak layout. To enable it, the only way I’ve found is to add the layout to /usr/share/X11/xkb/us. Then you can enable it through a GUI, or with command: setxkbmap us dvorak-intl-code It is optimized for multilinguists and hackers: // Dvorak international with dead keys and optimisations for code // Olivier Mehani (shtrom-xorg@ssji.net) &amp; James Pic // Reproduce the per-key mapping of us(intl) for the dvorak layout // aka "I just swapped my keys over" // Symbols and numbers swapped for code // colon and semi colon swapped for vim partial alphanumeric_keys xkb_symbols "dvorak-intl-code" { name[Group1]= "English (Dvorak international with dead keys)"; include "us(dvorak)" key <tlde> { [dead_grave, dead_tilde, grave, asciitilde ] }; key <ae01> { [ exclam, 1, exclamdown, onesuperior ] }; key <ae02> { [ at, 2, twosuperior, dead_doubleacute ] }; key <ae03> { [ numbersign, 3, threesuperior, dead_macron ] }; key <ae04> { [ dollar, 4, currency, sterling ] }; key <ae05> { [ percent, 5, EuroSign, dead_cedilla ] }; key <ae06> { [asciicircum, 6, onequarter, dead_circumflex ] }; key <ae07> { [ ampersand, 7, onehalf, dead_horn ] }; key <ae08> { [ asterisk, 8, threequarters, dead_ogonek ] }; key <ae09> { [ parenleft, 9, leftsinglequotemark, dead_breve ] }; key <ae10> { [ parenright, 0, rightsinglequotemark, dead_abovering ] }; key <ae11> { [ bracketleft, braceleft, guillemotleft, leftdoublequotemark ] }; key <ae12> { [bracketright, braceright, guillemotright, rightdoublequotemark ] }; key <ad01> { [ apostrophe, quotedbl, dead_acute, dead_diaeresis ] }; key <ad02> { [ comma, less, ccedilla, Ccedilla ] }; key <ad03> { [ period, greater, dead_abovedot, dead_caron ] }; key <ad04> { [ p, P, odiaeresis, Odiaeresis ] }; key <ad05> { [ y, Y, udiaeresis, Udiaeresis ] }; // key <ad06> { [ f, F ] }; // key <ad07> { [ g, G ] }; key <ad08> { [ c, C, copyright, cent ] }; key <ad09> { [ r, R, registered, registered ] }; key <ad10> { [ l, L, oslash, Ooblique ] }; key <ad11> { [ slash, question, questiondown, dead_hook ] }; // key <ad12> { [ equal, plus, multiply, division ] }; key <ac01> { [ a, A, aacute, Aacute ] }; key <ac02> { [ o, O, oacute, Oacute ] }; key <ac03> { [ e, E, eacute, Eacute ] }; key <ac04> { [ u, U, uacute, Uacute ] }; key <ac05> { [ i, I, iacute, Iacute ] }; key <ac06> { [ d, D, eth, ETH ] }; // key <ac07> { [ h, H ] }; key <ac08> { [ t, T, thorn, THORN ] }; key <ac09> { [ n, N, ntilde, Ntilde ] }; key <ac10> { [ s, S, ssharp, section ] }; // key <ac11> { [ minus, underscore, yen, dead_belowdot ] }; key <ab01> { [ colon, semicolon, paragraph, degree ] }; key <ab02> { [ q, Q, adiaeresis, Adiaeresis ] }; // key <ab03> { [ j, J ] }; key <ab04> { [ k, K, oe, OE ] }; // key <ab05> { [ x, X ] }; // key <ab06> { [ b, B ] }; key <ab07> { [ m, M, mu, mu ] }; key <ab08> { [ w, W, aring, Aring ] }; // key <ab09> { [ v, V ] }; key <ab10> { [ z, Z, ae, AE ] }; key <bksl> { [ backslash, bar, notsign, brokenbar ] }; include "level3(ralt_switch)" }; </bksl></ab10></ab09></ab08></ab07></ab06></ab05></ab04></ab03></ab02></ab01></ac11></ac10></ac09></ac08></ac07></ac06></ac05></ac04></ac03></ac02></ac01></ad12></ad11></ad10></ad09></ad08></ad07></ad06></ad05></ad04></ad03></ad02></ad01></ae12></ae11></ae10></ae09></ae08></ae07></ae06></ae05></ae04></ae03></ae02></ae01></tlde>

Automatic virtualenv activation

| by jpic | virtualenv python
This article proposes a proven standard which enables automatic virtualenv activation. Demonstration Before, I had to do something like: cd myproject source ../env/bin/activate Now I just do: cd myproject Virtualenv standard Say I have a project called projectX, you could expect to find it as such on my servers: /srv /projectX_prod /projectX_test /projectX_dev /projectX_dev_env -> the virtualenv /env -> symlink to projectX_dev_env /main -> the checkout of the python project As you can see, it is easy and consistent. Read More

Django schema migrations: nashvegas vs. South vs. evolution

| by jpic | django migrations
Schema migration consists of altering a database structure. For example, adding a column, an index … When creating a Django model, running the syncdb command can create the tables. But syncdb doesn’t support schema migrations. So when modifying a Django model, reflecting the changes on to the database is left as an exercice for the sysadmin. Django-extensions If you don’t speak fluent SQL, use the sqldiff command from django-extensions. It compares the database structure with the actual models for an app, and output SQL migration code. Read More

Coding standards for Django apps: names

| by jpic | django best-practice
This post shows a coding standard which emerged from the Pinax community (formerly hot-club)[source needed] for predictive and consistent URL naming patterns. While this is still supported by Django, namespaced URL include() has been as well for some years now and urls should be translated when upgrading Django versions. Django Contributing Commons maintains a technical description which you can reuse in your project. Check it out and try to contribute, this could be a nice community driven git based coding standards for Django ! Read More

Distro-agnostic craftman’s guide to python environment management

| by jpic | linux python
This article demystifies deployment of Python applications on any unix flavor. It’s distro agnostic approach is possible by a pragmatic use of each layer of a standard python application. This article targets system administrators and why not python developers as well? Crafting python Compiling Python is blazingly easy and fast, particularly for veteran php system administrators ! First things first, to see the compile flags of an existing python installation, the “sysconfig” module can be used: Read More

Django generic relations and performances: solutions

| by jpic | django contenttype
django-actream is a fresh and fantastic pluggable application for django. This article presents the solution to a simple performance issue: selecting followers and users who follow me through a generic foreign key … This article targets django users. The model At the time this article is written, this is what it looks like: class Follow(models.Model): """ Lets a user follow the activities of any specific actor """ user = models.ForeignKey(User) content_type = models. Read More

Howto: javascript popup form returning value for select like Django admin for foreign keys

| by jpic | php django javascript
This article presents a technique to get the return value of a form opened in a javascript popup, like Django admin for foreign keys. It can be used to improve the ergonomy relation select inputs. Introduction When a form allows to create or edit data, many to one (n:1) relations choices are often presented in a select input. For example, Django admin uses a select field by default for foreign keys. Read More
Previous Page 31 of 32 Next Page

They trust us

Contact

logo