Breyten Ernsting

Webdeveloper at Open State Foundation.

Tracking Django Projects in Recents

Recents is a nice little project that shows the programming projects you most recently worked on. An awesome idea, but it currently ships with only limited support for different kinds of development projects. More specifically, it has no support for Django projects yet. Fortunately, you can add it yourself.

Adding a Django project is pretty easy. You just click the wheel when you click on the icon in the menu bar and then it will start a text editor with the settings, which is a JSON structure. This structure is explained on the Github page. Of course, the key file for a Django project is obvious (manage.py). The only difficult thing is to figure out the name of the project. Recents has support to search the name of a project in a settings file. For a Django project, this settings file is usually manage.py as well. Most of the time, it will contain a line like this:

1
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app_name.settings")

From this line we can extract the project name using a regular expression. In the end, I ended up with the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
   "projectType":"django",
   "nameRegex":"\\s*os\\.environ\\.setdefault\\(\"DJANGO_SETTINGS_MODULE\", \"(.*)\\.settings\"\\)",
   "settingsFile":"manage.py",
   "image":"django.png",
   "keyFile":"manage.py",
   "projectRootRelativeToKeyFile":null,
   "filesExistInRoot":[
      "manage.py"
   ],
   "ignoreIfFilesInRoot":null,
   "ignoreIfPathContains":null,
   "button1":{
      "name":"Editor",
      "app":[
         "Sublime Text",
         "Sublime Text 2",
         "Coda 2"
      ],
      "arguments":""
   },
   "button2":{
      "name":"Terminal",
      "app":[
         "iTerm",
         "Terminal"
      ],
      "arguments":""
   },
   "button3":{
      "name":"Finder",
      "app":[
         "Finder"
      ],
      "arguments":""
   },
   "button4":null
}

If you want a nice little icon for your Django project, just pick an image and copy it to the /Applications/Recents.app/Contents/Resources/ directory and you’re done.

Comments