Client side validation for Django Forms

Posted on Wed 08 March 2017 in Django • Tagged with Django, FormsLeave a comment



In DUTH 2016 there was a session for Django Validation by Loïc Bistuer, in the session Loïc showed many areas you can validate user inputs from Django Form way to the Database Engine. To be honest validation in Django is a piece of cake and even if there is special validation rules you want to implement, you can still implement it, as I said it is easy and straight forward in Django, all of these validation is server side which happen on web server not on client-side, so what about client side?

What is client side validation?

In simple way, client side validation is validation user input on browser before sending the data to sever.

It is good practice to validate user inputs from client side to save roundtrips to server, but it needs extra work to implement your validations using JavaScript or using HTML5 form validation, but there is a way to replicate Django form validation to client side, let’s see how.

Django Parsley

Django Parsley is a Django app that replicate Django Form validation to client side using ParsleyJS library, and it’s so easy to use it.

How to use Django Parsley?

  • Install Django Parsley …

Continue reading

Django is boring but you can contribute

Posted on Sun 08 January 2017 in Community • Tagged with community, Django, duthLeave a comment

Bored employee in front of computer

I attended Django Under The Hood 2016, in sprints there is a comment passing around which Django is boring. Django is boring is actually a good news for the framework users, but it's sad one for developers want to contribute to the framework.

Every time I go to check Django tickets to contribute, I found they are difficult and in depth, because Django is a mature project now and the amount of contribution needed to the codebase is rare, but if you want to contribute you can check easy pickings tickets. In DUTH before the sprints projects leaders start to ask attendees for contributions, I found this is a good opportunity for me and for anyone wants to help the community and start to contribute to Django community.

Github duth contributions

If you want to contribute to Django and help the community, I have some suggestions for you:

  1. Write blog posts on How-tos, tips, and tutorials for Django, and Django packages for example Django REST Framework.
  2. Help Django team to move the ticket from stage to another.
  3. Contribute to one of Django’s packages, specially packages you are using, check their github page and help them.
  4. Tried more than one package for X …
Continue reading

Yet another and easier way to daemonize Celery

Posted on Mon 21 November 2016 in Django • Tagged with django, python, celeryLeave a comment

I wrote a post about how to run celery as daemon and it has many steps to do, many files to copy to your server, configure permissions, and configure upstart, but after sometime I found another and easier way to daemonize Celery.

In this method we will use supervisor to daemonize Celery, and this can be achieved by 3 simple steps, so let's do it.

Step 1

Install Supervisord sudo apt-get install supervisor on Ubuntu server. For other OSs please visit the official documentation

Step 2

This is the most important step, and in this step we will create supervisor configuration file to daemonize Celery.

Supervisor Configuration File

Celery project provide the basic configuration file in their Github repository.

Supervisor configuration files live in \etc\supervisor\conf\

Celery official configuration file

; ==================================
;  celery worker supervisor example
; ==================================

; Set full path to celery program if using virtualenv
command=celery worker -A proj --loglevel=INFO


; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs …
Continue reading

Add isort and flake8 test to your Django Project

Posted on Tue 27 September 2016 in Django • Tagged with django, python, unittest, howtoLeave a comment

Unit Test Works

In this post I'll tell you how to add isort and flake8 tests to your Django project test suite, this is simple script and you can start from this point and customize you own test suite.

As they said Django is a “batteries included” web application framework, and one of the batteries is Testing framework, testing in Django is easy and you can start writing tests even if you didn't do it before.

If you ever work with Django, you will write tests for your project, to test your views, models, forms, etc.. but it's better if you can add isort and flake8 tests to maintain the quality of your Python code.


We need some packages first so we can run the tests

pip install flake8 isort flake8-isort


It's better to create and use sperate virtualenv


flake8-isort is using .isort.cfg file to run the isort test against it, so let's add our configuration file.

.isort.cfg file

max_line_length = 120
indent_style = space
indent_size = 4
known_first_party = isort
ignore_frosted_errors = E103
skip =,build,.tox
balanced_wrapping = true
not_skip =

Test Python Script

Now it's time to write the Python script to run Django, isort, & flake8 tests.

runtests …

Continue reading

How to run Celery as daemon?

Posted on Tue 20 September 2016 in Django • Tagged with django, python, celeryLeave a comment

celery smoothy

Install upstart script


We need to make the user which will be used to run celery an owner of log and run directories.

sudo chown -R root:root /var/log/celery/
sudo chown -R root:root /var/run/celery/

Celery upstart

1- Download celeryd file from Celery official github repository.

2- Copy celeryd to /etc/init.d/celeryd

sudo cp celeryd /etc/init.d/

3- Make it executable

sudo chmod +x celeryd

4- Make it run on startup

sudo update-rc.d celeryd defaults
sudo update-rc.d celeryd enable

5- make it owned by root

sudo chown root:root celeryd

6- Done, now you can start/stop/restart celeryd as service

sudo service celeryd start
sudo service celeryd stop
sudo service celeryd restart

Celerybeat upstart

1- Download celerybeat file from Celery official github repository.

2- Copy celerybeat to /etc/init.d/celerybeat

sudo cp celerybeat /etc/init.d/

3- Make it executable sudo chmod +x celerybeat

4- Make it run on startup

sudo update-rc.d celerybeat defaults
sudo update-rc.d celerybeat enable

5- make it owned by root

sudo chown root:root celerybeat

6- Done, now you can start/stop/restart celerd as service

sudo service celerybeat start
sudo service …
Continue reading

DjangoCon Europe 2016, me, and Django Sprints

Posted on Wed 07 September 2016 in Community • Tagged with community, Django, DjangoConLeave a comment

djangocon logo

djangocon name tag

Late in 2014 I decided to shift my development stack from Microsoft .NET Framework to Django/Python stack. It's been almost 2 years now and I'm really enjoying and learning many things. I'm so happy that I've done this leap. In 2016 I had the change to attend DjangoCon Europe 2016 at Budapest, Hungry. I enjoyed it to the maximum, it's my first time to meet the community, and it's first time attending one of Django community events.

Django Community

When I started to learn Django, I found everyone is recommending Django documentation itself as start, from my past experience in .NET framework that its documentation is not enough to get your head around the framework, you need at least to read one book or watch one video course, but after reading Django official documentation, I was shocked that it's enough as start, it's enough for your daily tasks, it's enough to dive in Django framework, or fixing issues. The quality of Django official documentation is amazing.

When I went to DjangoCon Europe 2016 I saw people reflecting the philosophy of Django framework, the community is so welcoming as Django documentation, I had the chance to meet Russell Keith-Magee and …

Continue reading

PACKT publishing ebooks and videos 50% discount offer

Posted on Wed 17 February 2016 in Python • Tagged with django, python, ebooksLeave a comment

Generously PACKT publishing is offering 50% discount on Python and Django ebook and videos. PACKT has many Python ebooks and videos from novice to advanced level, it one of the most publishing company that releases books and videos for Python and Django, If you tried to Google a book for Python or Django, you differently will find one of their books in the search results.

Interesting ebooks and videos for Python:

Python Machine Learning

Mastering Python

Python DAta Analysis

Geospatial Development by Example Python

Interesting ebooks and videos for Django:

Web Development Django Cookbook

Django By Example

Master Django Web Developement


Please take the chance and buy your favorite Python or Django ebooks or videos form PACKT publishing. This offer is valid till 28th of March 2016 so please hurry up

  • For Python books and videos use PYTHON50 code.
  • For Django books and videos use DJANGO50 code.
Continue reading

Send Emails Asynchronously from Django

Posted on Sun 24 January 2016 in Django • Tagged with django, python, celery, emailsLeave a comment

In this article you will learn:

  1. How to send emails from Django.
  2. How to use Celery and Django-Celery-Email to send email asynchronously.

Last week I had the chance to get my hand dirty with Celery, I used it to send emails from Django project asynchronously using Django app call djnago-celery-email. What am I mean by sending emails asynchronously? I mean that user doesn’t wait for SMTP/mail server to send email message and give feedback to the web server, instead Django will call the send email procedure, pass it to Celery to do it away from Django application, so that user won’t wait, for example you want to send email to customer once he save customer information, you don’t want to keep user wait for application to save the customer data and send email, by sending email asynchronously user will only wait for saving confirmation and sending email celery will take care of it in the background.

Alt Text

Now let’s see how we can do that.

Step 1: Install and Setup Celery

  • In terminal, active your virtualenv and type $ pip install django-celery
  • Now celery and its Django app djcelery are installed into your virtualenv.
  • Next step is …
Continue reading

My Experience with Fitbit Customer Service

Posted on Wed 06 January 2016 in Review • Tagged with reviewLeave a comment


The start

I received Fitbit Flex as my birthday gift from my wife and I joined Fitbit community since 2013, I love the device and I love the sleep tracking feature, and with this feature now I can know why I'm feeling sleepy by data.

First Issue

Less than one year of using my Fitbit Flex, it started to not charging, and vibrating for alarms and feedback, so I created a support issue on Fibit support portal, and the quick answer was, Oh we are sorry please give us an address so we can send you another one. I got shocked, this reminded me of Amazon Customer Service quality. fitbit support 01

Second Issue

After receiving the second Fitbit Flex, I used it for while and the wristband got damaged, I created a support issue again, they request a confirmation that my band is damaged, I replied with images, and boom the same response "Oh we are sorry please give us an address so we can send you another one". Fitbit Support 02

Third Issue

My replacement Fitbit Flex got damaged also and again I created support issue, and this time they were more awesome than before, they sent me a replacement though my warranty is …

Continue reading

DotPen review

Posted on Mon 28 December 2015 in Review • Tagged with reviewLeave a comment

I bought an iPad Mini 2 to write paper-less/eletronic notes instead of having notebook and a pen always inside my pockets, I blogged about it before, but I upgraded my stylus from Moshi Stanza Duo to DotPen, and I want to share my experince with you.

My Experience


If you want a stylus that is perfect for hand writing, buy DotPen.

dotpen I'm using DotPen now for two month, and I'm so happy about it, it feel like writing on paper but instead I'm writing on my iPad mini 2, and best part that it can support any note taking app, I'm using it with GoodNotes and Penultimate and it's perfectly working with them. Here is comparison between my handwriting on paper and on iPad using dotPen. paper-less Note

Some Features

  • It's not bluetooth stylus which can sync with apps to enable plam rejection feature, so that why I recommned using it with Goodnotes becasue of the writing panel.
  • It has On/Off button which I found it's taking it really off, my iPad mini 2 can't recognize its tip if it's off.
  • It take AAA battery which can run it for 2 weeks at least, you won't change the …
Continue reading