Services Blog Français

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.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField() 
    actor = generic.GenericForeignKey()

    class Meta:
        unique_together = ("user", "content_type", "object_id")

The model has two relations:

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

How to override a view from an external Django app

| by jpic | django python best-practice

This article describes how to override a view from an external Django app which is a FAQ on StackOverflow and IRC.

You should understand that your urls.py is a really central and critical part of your django project.

You don’t touch external app code

You are not supposed to edit the code from an external app. Unless you fork it first on github.

How to override without forking

Overriding a template

If you want to override templates/userena/activate_fail.html, then all you have to do is create your own templates/userena directory and make your own activate_fail.html in it.

Read More

Django, Pinax, virtualenv, setuptools, pip, easy_install and requirements.txt

| by jpic | django pinax python virtualenv best-practice

This article describes how to build project dependencies with virtualenv. It is appliable to Pinax. Pinax uses virtualenv by default. It lets the developer have a project-specific python directory, including binaries, packages etc … OpenSuse for example supplies very bad Pinax packages which allows the user to mess with his operating system. It is much better to isolate project dependencies from a project to another for more granular control of the maintenance cost; for example if a package upgrade breaks the user project.

Read More

Disk space WTF

| by jpic | linux

What do you think is the problem when vim starts complaining that it can’t write swap files, postgresql starts complaining that there is no disk space left, when df output is:

>>> df 
Filesystem     1K-blocks     Used Available Use% Mounted on
udev               10240        4     10236   1% /dev
run                10240      156     10084   2% /run
/dev/md1        10403064  1298596   8580184  14% /
shm              8188088        0   8188088   0% /dev/shm
tmpfs            8188088      124   8187964   1% /tmp
/dev/md2       105366664 62467912  37588548  63% /home

This post also credits the awesomeness of Open Source and particularly community driven support

Read More

Survive linux (*nix) permissions

| by jpic

It is common for junior developers and system administrators to be blocked because of permissions. This article describes how to identify and fix a permission issue, as this is a FAQ on StackOverflow.

Identifying permission issues

Here a self explaining case, probably the easiest, which happens when trying to access something which is directly blocked by the lack permissions:

>>> mkdir /mnt/foo
mkdir: cannot create directory `/mnt/foo': Permission denied

Now a more obscure cases. In this example, “james” is the owner of the hello file and thus should be able to read and write it:

Read More
Previous Page 32 of 32

They trust us

Contact

logo