Month: May 2013

Solve Django Grappelli Delete or Action dropdown menu doesn’t works

Solve Django Grappelli Delete or Action dropdown menu doesn’t works

Apparently, Django-grappelli action menu drop-down doesn’t works with default Django 1.4. I tried select item and go to drop-down menu to delete that, but nothing happened. This is errors from Firebug: 12 $("tr input.action-select").actions(); TypeError: $(…).actions is not a function And the problem apparently located in STATIC_FILEFINDER which FILESYSTEM finder above AppDirectoriesFinder. This is the solution: …

+ Read More

Run standalone python scripts in Django 1.5

Run standalone python scripts in Django 1.5

Since setup_environ is deprecated in Django 1.5, we can use os.environ to load environment and run standalone python script. At this example: 1234567myproject     |     |     —- myapp            |            |             ——– standalone_scripts_is_here.py And here …

+ Read More

Lock 3G 4G network in Nokia Lumia Windows Phone

Lock 3G 4G network in Nokia Lumia Windows Phone

I use Nokia Lumia 920 at this example. To lock Nokia lumia network on 3G / 4G only, we can do quick setup by: 1. Go to dial-pad Type : ##3282 and call For older version, please type : ##3282#. Click settings on right-bottom From this settings, we can set network running on 2G only, …

+ Read More

Browsing with minibrowser and proxy settings using PyQt4

Browsing with minibrowser and proxy settings using PyQt4

When it comes need to have browser that we will using with specific task and run behind proxy, we can rely on PyQT4. Here is the the code that taken from : http://code.activestate.com/recipes/576921-using-proxy-connection-for-qwebview/ 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273## {{{ http://code.activestate.com/recipes/576921/ (r4) import os import sys from PyQt4.QtCore import * from PyQt4.QtGui import * from PyQt4.QtWebKit import * from PyQt4.QtNetwork …

+ Read More

Install Spynner on Virtualenv

Install Spynner on Virtualenv

Installing Spynner which using Qt4 and autopy module as it 3rd party is can’t run smooth under virtualenvironment. Thigs to do here : 1. Install Qt4 and make it works with Virtualenv Follow this links Install pyqt4 on virtualenvironment 2. Install autopy under Virtualenv We may facing several errors while installing autopy under Virtualenv. Xtest.h …

+ Read More

Add PyQt4 on virtualenv Python

Add PyQt4 on virtualenv Python

If we want to make PyQt4 accessible from virtualenv, we can put this scripts into “~/.virtualenvs/postmkvirtualenv”: 123456789101112131415#!/bin/bash # This hook is run after a new virtualenv is activated. LIBS=( PyQt4 sip.so ) PYTHON_VERSION=python$(python -c "import sys; print (str(sys.version_info[0])+’.’+str(sys.version_info[1]))") VAR=( $(which -a $PYTHON_VERSION) ) GET_PYTHON_LIB_CMD="from distutils.sysconfig import get_python_lib; print (get_python_lib())" LIB_VIRTUALENV_PATH=$(python -c "$GET_PYTHON_LIB_CMD") LIB_SYSTEM_PATH=$(${VAR[-1]} -c "$GET_PYTHON_LIB_CMD") …

+ Read More

Install Python 2.7 Debian 6.0. Squeeze

Install Python 2.7 Debian 6.0. Squeeze

Here are guide to install Python 2.7 into Debian 6.0 Squeeze 1. Add new repo into “/etc/apt/sources.list” 1deb http://ftp.uk.debian.org/debian/ testing main contrib non-free 2. Update and Upgrade 1apt-get update && apt-get upgrade -y 3. Install python 2.7 and set as default 123apt-get install libc6-dev apt-get install python2.7 update-alternatives –install /usr/bin/python python /usr/bin/python2.7 10

Django log format app name and function and saved into file

Django log format app name and function and saved into file

This is quick configuration for Django logger to log with application name followed with function, and store them into log files. 1. Edit logger settings settings.py 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465import os CURRENT = os.path.dirname( __file__ ) LOGGING = {     ‘version’: 1,     ‘disable_existing_loggers’: False,     ‘filters’: {         ‘require_debug_false’: {   …

+ Read More

Create custom view and page on Django admin

Create custom view and page on Django admin

We can customize Django Admin with custom views and pages. Here are the steps to do: 1. Configure Admin URL Edit urls.py and append new admin views before “admin.site.urls” : 123    …     url(r’^admin/item/$’, ‘products.views.admin_products’),     url(r’^admin/’, include(admin.site.urls)), 2. Create Django admin custom views Create new admin function view: 123456789101112131415161718@login_required def admin_products(request): …

+ Read More

Setup git server with Amazon EC2

Setup git server with Amazon EC2

We can setup git server on amazon ec2 intances using gitolite. Here is step to do: 1. Configure SSH config Create new file “~/.ssh/config” which contains your amazon EC2 hostname, user and PEM key location. 1234Host amazon Hostname 23.21.1xx.xxx User root IdentityFile /home/yodi/my-ec2-micro.pem With this configuration, we can login into EC2 instance with : “ssh …

+ Read More

Make auto populated slug field in Django admin

Make auto populated slug field in Django admin

Django admin have great feature called “prepopulated”. Here is an example to create auto populated slug in Django admin without using any additional Jquery scripts. 1234567891011from django.contrib import admin from photos.forms import PhotoAdminForm from photos.models import Photo class PhotoAdmin(admin.ModelAdmin):     list_display = (‘title’, ‘admin_image’)     prepopulated_fields = {‘slug’:(‘title’,)}     form = PhotoAdminForm …

+ Read More