Author: yodi

Install Celery 3.1.25 in Django 1.10 with Ubuntu 16.04 Production

Install Celery 3.1.25 in Django 1.10 with Ubuntu 16.04 Production

Celery is awesome tools to manage queue in Django. It’s can reduce processing time in serial / sync process. For instance, we have schema for registering user: 1. User click on Sign-up Button 2. We create and save into records (1 second) 3. Signals trigger send SMS to User (1 second) 4. Signals trigger send …

+ Read More

Installing Fatfreecrm in Ubuntu

Installing Fatfreecrm in Ubuntu

Here are the quick guide: 1sudo apt-get install ruby-dev libsqlite3-dev ruby libmagick++-dev libxml2 libxml2-dev libxslt1.1 libxslt1-dev libyaml-dev libpq-dev Then follow this: http://guides.fatfreecrm.com/Setup-Linux-or-Mac-OS.html Now for passenger: 12345cd fat_free_crm rvm install ruby-2.3.3 rvm gemset empty gem install bundler bundle install Configure `/etc/passenger/fat_free_crm.yml` and edit NGINX 123456789101112131415server {     listen       80;     server_name …

+ Read More

Fix SSL not working on mobile browser RapidSSL

Fix SSL not working on mobile browser RapidSSL

To solve this, we need to make sure our installation of SSL is correct. Please check your current website via https://cryptoreport.rapidssl.com/checker/views/certCheck.jsp. It will show you the missing SSL Certificate. Please download it into your server. The next step will be: 1. go to /etc/ssl 2. move your current domain.crt into another file 3. then concatenate …

+ Read More

Install Zurmo CRM in Ubuntu 16.04 Xenial Xerus

Install Zurmo CRM in Ubuntu 16.04 Xenial Xerus

Here are step to install Zurmo CRM into Ubuntu 16.04 Xenial Xerus. Since Ubuntu 16.04 doesn’t have php5, we would like to install PHP5 1234sudo apt-get install software-properties-common sudo apt-get purge `dpkg -l | grep php| awk ‘{print $2}’ |tr "\n" " "` sudo add-apt-repository ppa:ondrej/php sudo apt-get update 1. Install php5.6 1sudo apt-get install …

+ Read More

Setup Django + WordPress Ubuntu 16.04 Xenial Xerus

Setup Django + WordPress Ubuntu 16.04 Xenial Xerus

Here is guide to setup Ubuntu 16.04 Xenial Xerus for Django and WordPress Development. First, we need to install dependencies software. 1. Install dependencies software Python, NGINX, PosgreSQL, MySQL and PHP5 1sudo apt-get install libpq-dev python-dev python-software-properties postgresql postgresql-contrib nginx git zip unzip build-essential python nmap libxslt1-dev python-pip imagemagick uwsgi uwsgi-plugin-python nmap mysql-server phpmyadmin libffi-dev …

+ Read More

Setup New Server Ubuntu 14.10 with Django, Python and PHP

Setup New Server Ubuntu 14.10 with Django, Python and PHP

Here is quickstep to configure a new server in Softlayer for Django and PHP development environtment. 12sudo apt-get update && sudo apt-get upgrade sudo apt-get install libpq-dev python-dev python-software-properties postgresql postgresql-contrib nginx git zip unzip build-essential python nmap libxslt1-dev python-pip imagemagick uwsgi uwsgi-plugin-python nmap mysql-server phpmyadmin libffi-dev libmysqlclient-dev libmysqlclient-dev libmysqlclient18 For Django sites-enables/ : 12345678910111213141516171819202122232425262728293031323334353637server …

+ Read More

Open Permission access custom for Django Rest Framework

Open Permission access custom for Django Rest Framework

When we need to open access for API Django-restframework, we can do it by extending the permission class. Here is some example: 123456789101112131415161718192021class PublicUserPermissions(permissions.BasePermission):     """     Granting public access permissions     """     def has_object_permission(self, request, view, obj):         # Allow get requests for all     …

+ Read More

Setup SSL Certification RapidSSL on EC2

Setup SSL Certification RapidSSL on EC2

Here are quickstep to generate SSL Certification 12openssl genrsa -out www.domain.com.key 2048 openssl req -new -key www.domain.com.key -out www.domain.com.csr 123456789101112Country Name (2 letter code) [AU]:ID State or Province Name (full name) [Some-State]:Jakarta Locality Name (eg, city) []:Jakarta Organization Name (eg, company) [Internet Widgits Pty Ltd]:PT POLATIC INFORMATIKA INDONESIA Organizational Unit Name (eg, section) []:IT Common …

+ Read More

Running Play Framework as services in Production Ubuntu

Running Play Framework as services in Production Ubuntu

Here are steps to deploy Play Framework to Ubuntu as services : 1. Stage 1activator stage 2. Setup services in /etc/init.d/your-play 12345678910111213141516171819202122232425262728293031323334#!/bin/sh ### BEGIN INIT INFO # Provides:          mdm # Required-Start:    $local_fs $remote_fs $network $syslog # Required-Stop:     $local_fs $remote_fs $network $syslog # Default-Start:     2 3 4 …

+ Read More

Solve integrity error duplicate key in Django PostgreSQL

Solve integrity error duplicate key in Django PostgreSQL

This error caused by we’re using database from copy / clone database. The sequences will be mixed-up. To solved this, just follow this way : 12python manage.py sqlsequencereset <app-name> > app.sql psql -U username -d database -a -f < app.sql Then your problem shall gone!

Tutorial Implementation Google Cloud Messaging (GCM) with Django

Tutorial Implementation Google Cloud Messaging (GCM) with Django

Setup GCM for Android Client and Django in Server require efforts to know how it’s works. Here are simple steps to setup the newest GCM (Google Cloud Messaging) in Android. To understand about GCM, the flow is : 1. Create a Google APIs GCM project, which generates SENDER_ID and API_KEY for server implementation. 2. An …

+ Read More

LAMPP Ubuntu in Softlayer

LAMPP Ubuntu in Softlayer

Quick guide for setup LAMPP server in Ubuntu : 12sudo apt-get update && sudo apt-get upgrade -y sudo apt-get install nginx php5-fpm php5-mysql mysql-server php5-mysql php5-dev php-pear php5 nmap vim

How to enable WSGIPassAuthorization in NGINX + DJango

How to enable WSGIPassAuthorization in NGINX + DJango

Just in case we need to enable “WSGIPassAuthorization” in NGINX, we can put this in nginx hosts 12345proxy_pass_request_headers on; proxy_no_cache $cookie_nocache  $arg_nocache$arg_comment; proxy_no_cache $http_pragma     $http_authorization; proxy_cache_bypass $cookie_nocache $arg_nocache $arg_comment; proxy_cache_bypass $http_pragma $http_authorization;

ERP Development Design

ERP Development Design

Here are the list we need consider when develop ERP. More in technical view. 1. Never trust Front-end validation We must separate between front-end validation and backend validation. Always check validation on backend to make sure the data is valid and correct. To avoid any data updates in the middle of process. 2. Audit-trail Audit-trail …

+ Read More

Upload PostgreSQL not working, change the encoding may help

Upload PostgreSQL not working, change the encoding may help

When we upload and restore the backup into new postgresql server, sometimes we facing problem because encoding. To solve this, we can use UTF-8 : 1update pg_database set encoding = pg_char_to_encoding(‘UTF8’) where datname = ‘your-database’;

Uwsgi on ubuntu 14.04 not working solution

Uwsgi on ubuntu 14.04 not working solution

In Ubuntu 14.04, uwsgi that installed via apt-get will not working. To make it working, please use this steps: 12sudo apt-get remove –purge uwsgi uwsgi-plugin-python sudo apt-get install uwsgi uwsgi-plugin-python Then follow this steps: 1234sudo pip install uwsgi cd /usr/bin sudo mv uwsgi uwsgi-old sudo ln -s /usr/local/bin/uwsgi uwsgi If still failed, follow this : …

+ Read More

Setup Ubuntu Server in Softlayer for Django

Setup Ubuntu Server in Softlayer for Django

Here are a quick step to setup Ubuntu server in Softlayer for Django 1. Install depedencies 1234apt-get install python-software-properties software-properties-common add-apt-repository ppa:webupd8team/java apt-get update sudo apt-get install oracle-java7-installer 2. Install UWSGI, Python, PostgreSQL and other modules 1sudo apt-get install libpq-dev python-dev python-software-properties postgresql postgresql-contrib nginx git zip unzip build-essential python nmap libxslt1-dev python-pip imagemagick uwsgi …

+ Read More

Becareful using int() or Decimal() for validation storing in Charfield Django

Becareful using int() or Decimal() for validation storing in Charfield Django

So, we have CharField() as model field in Django. Then we want to validate input into number only. Usually, we using obj.is_digit() to validate. Common mistake happen when we using int() to convert string input. 12value = "0123123123" int(value) Will return 1"123123123" So becareful when using int() or Decimal() for converting value with leading zero

Update parent after children new windows closed

Update parent after children new windows closed

Here is a snippet to update parent after new window getting closed : 12345678910111213141516171819// Start trigger pop-up new window var createUrl = $(this).data(‘url’) + selectedUUID; newwindow = window.open(createUrl, ‘Some Page, ‘scrollbars=yes,resizable=yes,height=600,width=’+screen.width/2); // Set focus on windows if (window.focus) {     newwindow.focus(); } // Update parent once children window already closed // Reload jqgrid table …

+ Read More

JqGrid inline editing integration with DJango send csrf token

JqGrid inline editing integration with DJango send csrf token

Here is a quick snippet to send csrf_token in POST data from inline edit JqGrid to Django: 12345678910111213141516var tableGrid = $(selector).jqGrid({    ….    onSelectRow: function(id){          if(id && id!==lastSel){             $(selector).restoreRow(lastSel);             lastSel=id;          }       …

+ Read More

Example Jquery Plugin to filtering input value real-time with Regex validation

Example Jquery Plugin to filtering input value real-time with Regex validation

We try to add real-time input validation for dynamic element with some regex. Let say, user allowed only to type “numeric” and disallow any others alphabet and symbols. Then, we can write a small plugin, at this example, i use https://github.com/akzhan/jquery-keyfilter for Regex validation. Then, we just need to write this simple and easy plugin …

+ Read More

Handle error form.save() with model validation

Handle error form.save() with model validation

Here is a quick snippet to avoid form.save() error because model validation : 12345678# handle form save with model validationerror # http://stackoverflow.com/questions/8771029/django-raise-a-validation-error-in-a-models-save-method try:     form.save() except ValidationError, e:     form._errors = {}     for _, v in e.message_dict.items():         form._errors.setdefault(NON_FIELD_ERRORS, []).extend(v)

Inline edit jqgrid with select2

Inline edit jqgrid with select2

Here is a quick snippet for inline edit JqGrid with Select2 First, we need to bind colModel with select2 in dataInit : 1234567891011121314var colModel = [      // always put uuid and id      {name:’id’, hidden: true},      {name:’uuid’, hidden: true},      {name:’youroption’, label:’yourlabel’,editable: true,       edittype: "select", editrules: …

+ Read More

Jqgrid for Dummies

Jqgrid for Dummies

Here is a quick snippet of how to using JqGrid for dummies, like get data, delete data, access data or data manipulation. Setup JQGrid: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970$(document).ready(function() {     // Enable tooltips $("body").tooltip({     selector : ‘[data-toggle="tooltip"]’ }); $(".chosen").chosen(); var permission = $(‘.permission’); // Define ID for table var selector = "#table-index"; var pager = …

+ Read More

JqGrid save inline editing callback

JqGrid save inline editing callback

Here is a quick snippet for callback when saving inline editing in JqGrid: 123456789101112// http://stackoverflow.com/questions/13303698/total-of-amount-in-jqgrid ondblClickRow: function (rowid, name, val, iRow, iCol) {     $(selector).jqGrid("editRow", rowid, {         keys: true,         aftersavefunc: function (rowid) {             var $grid = $(selector);       …

+ Read More

JqGrid delete multiple select rows

JqGrid delete multiple select rows

There is an issue if we delete rows using : 12345678910// Get all selected row var rows = $(selector).jqGrid("getGridParam", "selarrrow"); console.log(rows); // Iterate and delete for (var i in rows) {       console.log(i);       console.log(rows[i]);       $(selector).jqGrid(‘delRowData’, rows[i]); } Only a few records will deleted. The solution : 12345678910111213/** …

+ Read More

Save django model with dictionaries

Save django model with dictionaries

Beware when queryset filter update() because it will pass model validation. Here is some example save model with dictionaries : 12345678910for k, v in account.items():     setattr(instance, k, v) try:     instance.save() except Exception, e:     raise ValidationError(e) else:     updated += 1     # print account