Solve Django Filter queryset result duplicates with Pagination

Solve Django Filter queryset result duplicates with Pagination

When we filter using multiple filter and mixed with django pagination, somehow the results are duplicates. This is incorrect. Apparently, looking at the source code https://github.com/alex/django-filter/blob/master/django_filters/filters.py#L105, I found this line: 1234q = Q() for v in value:     q |= Q(**{self.name: v}) return qs.filter(q).distinct() By default, django-filter not using “AND” condition and that’s why …

+ Read More

Setup Django and Timezone follow server datetime (Ubuntu)

Setup Django and Timezone follow server datetime (Ubuntu)

Here is quickfix to setup Django working with server timezone. 1. Set Server Timezone Check by : 12date Mon Jan  5 10:54:38 WIB 2015 If this not correct or you want to change server timezone, then edit “/etc/timezone” 1Asia/Jakarta Then do : 12sudo dpkg-reconfigure –frontend noninteractive tzdata date Now you should see the updated server …

+ Read More

Django django-admin.py startproject ImportError

Django django-admin.py startproject ImportError

Suddenly i got this error in Windows when trying to start a new Django project : 1django-admin.py startproject ImportError: No module named django.core The solution : 1python C:\Python27\Scripts\django-admin.py startproject example

Set Ofbiz using database PostgreSQL

Set Ofbiz using database PostgreSQL

Here is a quickstep to set OfBiz running using PostgreqSQL 1. Install PostgreSQL Driver Download http://jdbc.postgresql.org/download/postgresql-9.3-1102.jdbc4.jar and put it on “ofbiz\framework\entity\lib\jdbc” 2. Setup new account and database In Pgadmin, right click on “Login Role” and create a new account “ofbiz” with password “ofbiz”. Also create database called “ofbiz” and the owner is “ofbiz”. Make sure …

+ Read More

Install and setup Ofbiz in Windows Server

Install and setup Ofbiz in Windows Server

1. Download and install Java JDK (I prefer 1.7) and set JAVA_HOME in Global Environment Variables into your jdk : Example : C:\Program Files\Java\jdk1.7.0_45 2. Go to http://www.apache.org/dyn/closer.cgi/ofbiz/apache-ofbiz-13.07.01.zip and select mirror to download 3. Extract the package into your local folder 4. Open your command-prompt, and do : 12ant load-demo ant start 5. Now open …

+ Read More

Install OpenERP in Windows Server / 8

Install OpenERP in Windows Server / 8

Here is a quickstep to install openerp in windows : 1. Download OpenERP http://nightly.odoo.com/8.0/nightly/exe/odoo_8.0.latest.exe 2. Setup Postgresql Account I assume we already have postgresql in our Windows. Go to PgAdmin -> Server -> Login Role. Right click on Login Role and select New Login Role. Create a new account called “odoo” with create database permission. …

+ Read More

How to rollback or remove last commit in remove Git

How to rollback or remove last commit in remove Git

This is common thing can happen when we push bad commit and want to rollback into previous commit. Please try this in your own branch before apply into production / master. Try with “git log” : 1234567891011commit 10a8e361b35dd8131cb1ba3e606aad35d0d0f267 Author: Somebody Date:   Fri Dec 26 13:02:33 2014 +0700      Bad commit here commit f89150c864cd4725a25995efd233f5beab7fc25d …

+ Read More

Setup rsync in Windows

Setup rsync in Windows

Please go to http://www.rsync.net/resources/howto/windows_rsync.html and download the software. Then you can add “C:\Program Files (x86)\cwRsync\bin” into your global variable path

Set Postgresql open for remote access in EC2

Set Postgresql open for remote access in EC2

To make PostgreSQL can be accessible from remote, first in EC2 security, please open your port “5432” (if your installation is using default port). Next, we need to edit pg_hba.conf : /etc/postgresql/9.3/main/pg_hba.conf and add : 1host    all             all             0.0.0.0/0       …

+ Read More

Celery as daemon service in Ubuntu for production

Celery as daemon service in Ubuntu for production

Here is a quickstep to set Celery as daemon in Ubuntu 14.04 for production: Create file “/etc/init.d/celeryd” : 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395#!/bin/sh -e # ============================================ #  celeryd – Starts the Celery worker daemon. # ============================================ # # :Usage: /etc/init.d/celeryd {start|stop|force-reload|restart|try-restart|status} # :Configuration file: /etc/default/celeryd # # See http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html#generic-init-scripts ### BEGIN INIT INFO # Provides:         …

+ Read More

Install OpenERP in Ubuntu

Install OpenERP in Ubuntu

To install open-erp in Ubuntu : 123wget -c https://raw.githubusercontent.com/aschenkels-ictstudio/openerp-install-scripts/master/odoo-v8/ubuntu-14-04/odoo_install.sh chmod a+x odoo_install.sh ./odoo_install.sh Edit “/etc/odoo-server.conf” : 12345678[options] ; This is the password that allows database operations: ; admin_passwd = admin db_host = localhost db_port = 5432 db_user = username db_password = password addons_path = /usr/lib/python2.7/dist-packages/openerp/addons Make sure your add username and password PostgreSQL account that …

+ Read More

Install Django in Windows 8 / 7

Install Django in Windows 8 / 7

Here is quick step to setup Django in windows box : 1. Install Python Please download https://www.python.org/ftp/python/2.7.7/python-2.7.7.msi. 2. Install Setuptools http://www.lfd.uci.edu/~gohlke/pythonlibs/4jci5y59/setuptools-5.8.win32-py2.7.exe 3. Install PIP http://www.lfd.uci.edu/~gohlke/pythonlibs/4jci5y59/pip-1.5.6.win32-py2.7.exe 4.Don’t forget to set global environment variables (depend on your Python path installation) In PATH, please add : 1C:\Python27\;C:\Python27\Scripts;C:\Python27\Lib\site-packages\django\bin; 5. Install Django 1pip install django 6. Create new django project …

+ Read More

Solve RabbitMQ ERROR: epmd error for host “ubuntu”: address (cannot connect to host/port)

Solve RabbitMQ ERROR: epmd error for host “ubuntu”: address (cannot connect to host/port)

When installing RabbitMQ in server, I got this errors: 123456789101112131415161718192021Preparing to unpack …/rabbitmq-server_3.2.4-1_all.deb …                 Unpacking rabbitmq-server (3.2.4-1) …                                     yProcessing triggers for man-db (2.6.7.1-1) …           …

+ Read More

Configure Django Celery, RabbitMQ in Windows and periodic task

Configure Django Celery, RabbitMQ in Windows and periodic task

Here is guide to setup Django, Celery, RabbitMQ in Windows and running periodic task. 1. Install RabbitMQ Go to http://www.rabbitmq.com/download.html, install and check if the services already running 2. Setup celery in your Django Project Install django-celery modules 1pip install django-celery 3. Example configuration for periodic task In this example, i create tasks.py in app …

+ Read More

Solve vcvarsall.bat Python Windows installation

Solve vcvarsall.bat Python Windows installation

When installing python modules in Windows 8, this errors is very common and very hard to find solution. I spent 2 hours only to solve this issues 1Unable to find vcvarsall.bat The solution is quite straight-forward: 1. Install Visual Studio 2008 VC Setup http://go.microsoft.com/?linkid=7729279 VS 2008 : http://download.microsoft.com/download/E/8/E/E8EEB394-7F42-4963-A2D8-29559B738298/VS2008ExpressWithSP1ENUX1504728.iso 2. Install Microsoft SDK http://www.microsoft.com/downloads/details.aspx?FamilyId=F26B1AA4-741A-433A-9BE5-FA919850BDBF&displaylang=en 3. After …

+ Read More

Setup Queue in Django using Celery and RabbitMQ

Setup Queue in Django using Celery and RabbitMQ

I’m using Ubuntu for setup queue in Django using celery and rabbitmq. Go to console and we need to install rabbitmq at first: 1. RabbitMQ 1234wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc sudo apt-key add rabbitmq-signing-key-public.asc sudo apt-get update sudo apt-get install rabbitmq-server To adjust system limits (in particular the number of open file handles), edit the file /etc/default/rabbitmq-server to …

+ Read More

Update reference models in Haystack problem solved

Update reference models in Haystack problem solved

When we put reference model in part of index and get updated, it will NOT changed in main model. Here is some example: models.py 12345class UserProfile(CommonInfo):     city = models.ForeignKey(City)     def __unicode__(self):         return unicode(self.code) With search indexes : userprofile.txt 1{{ object.city.name }} When “CITY” models is updated, let …

+ Read More

Jquery Icheck checkbox checked or not

Jquery Icheck checkbox checked or not

Here is snippet to check if checkbox is checked or not in Jquery iCheck: 12345$(‘input[name="some-input-name"]’).on(‘ifToggled’, function (event) {            if ($(this).is(‘:checked’)) {                alert(‘checked’);             }         });

Solve ImportError: cannot import name IncompleteRead

Solve ImportError: cannot import name IncompleteRead

When doing “pip install -r requirement.txt”, suddenly i got this erros out of nowhere. Fyi, I’m suspecting upgrade “requests” module may cause this issue. 12345678910111213141516Traceback (most recent call last):   File "/usr/bin/pip", line 9, in <module>     load_entry_point(‘pip==1.5.4’, ‘console_scripts’, ‘pip’)()   File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 351, in load_entry_point     return get_distribution(dist).load_entry_point(group, name)   File …

+ Read More

TypeError: __init__() got an unexpected keyword argument ‘preserve_default’

TypeError: __init__() got an unexpected keyword argument ‘preserve_default’

Quickfix to solve ; 12345678    migration_module = import_module("%s.%s" % (module_name, migration_name))   File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module     __import__(name)   File "D:\Python\vasham\dashboards\migrations\0004_auto_20141112_1644.py", line 7, in <module>     class Migration(migrations.Migration):   File "D:\Python\vasham\dashboards\migrations\0004_auto_20141112_1644.py", line 18, in Migration     preserve_default=True, TypeError: __init__() got an unexpected keyword argument ‘preserve_default’ Is 1pip install django …

+ Read More

Installing Process Designer in Windows 8 / Server 2012

Installing Process Designer in Windows 8 / Server 2012

After download Process Designer from IBM BPM, then you can go : 1C:\Program Files\IBM\Installation Manager\eclipse Execute eclipse. Then in preferences, just add the repository to Process Designer folder : 1D:\IBM\IBM Process Designer\IMPD85\repository.config

Setup IBM BPM in Azure

Setup IBM BPM in Azure

Here is step to setup IBM BPM in Azure. 1. Setup VM 2. Enable ports using Azure Powershell After login into Windows: 1. Enable policy rules for IBM BPM ports 2. Install DB2 3. Create database http://www-01.ibm.com/support/knowledgecenter/SSFPJS_8.5.0/com.ibm.wbpm.imuc.ebpm.doc/topics/db_create_nd_win_db2.html After installed, run “db2cmd”: 12345db2 create database PDWDB automatic storage yes  using codeset UTF-8 territory US pagesize 32 …

+ Read More

Github keep tracking and what is for ?

Github keep tracking and what is for ?

When working with github, we usually do “push” and “pull” followed by “origin master” or “origin branch-name”. We can just use “git pull” or “git push” and will followed by the current branch. For global push config using current: 1git config –global push.default current Example, we currently at branch “dev”. To push update, we can …

+ Read More