Extend Django User Model and Generic Class Based View "GCBV"

Posted on Fri 18 December 2015 in Django • Tagged with Django, PythonLeave a comment

1450356512_full.png When I started to learn Django, I used to use the function based view aka FBV and in my current project I decided to learn class based view CBV, I watched one DjangoCon videos by Andrew Pinkham to make this easier on me, and if you tried or planning to learn CBV, you will be confused about the class based views and the generic class based views inside Django, it’s some many of them, please watch the video to get your head around it. OK, now I’ve done my homework and it’s time to use CBV, believe me it’s easy and you will find the number of code lines inside our views will be decreased specially if you use GCBV. User Model and GCBV

What is the relation between GCBV and User Model?

Great question, while I’m working with one of my models fro example her the Teacher model, and teacher will has a user credentials in order to user the app. The easiest and the straightforward way is to make one-to-one relation with django.contrib.auth.models.User please read the quote from Django documentation:

There are two ways to extend the default User …

Continue reading

My journey from paper note to paperless note

Posted on Sun 13 December 2015 in Developer • Tagged with notes, paprelessLeave a comment

paperless note on iPad

I really love to take notes wherever and wheneve. I like to keep my notes with me, but after buying iPad mini I decide to change my note tool from paper notes to paperless notes (e-notes), but I like to hand writing my notes I want something that feels like paper notes.

Searching for the tool

I thought of buying a stylus for iPad that feels like real pen and start taking notes, first I found fiftythree Pencil but it was built mainly for designers not for writing, then I found The best stylus for me is the Jot Script but it is expensive but it has the best writing experience and best accuracy. This is for the stylus, for the application I searched about note application that can enhance my writing accuracy, I found two note apps:

  • Penultimate Evernote

    • Free

    • Sync with Evernote

    • Zoom in and write with line recognition

  • Goodnotes

    • Paid (but worth every penny)

    • Backup with most of cloud storages like Google Driver, Dropbox, & OneDrive.

    • Pen size & color customization.

    • Palm rest and palm rejection.

    • Add annotations to PDF files.

    • Writing panel.

    • Shape recognition.

My final tools

Device: iPad mini with retina display.
Note App: Goodnotes.
Stylus: Moshi …

Continue reading

Solution for psycopg2 installation error with Mac OSX El Capitan

Posted on Sun 11 October 2015 in Development • Tagged with developement, macosxLeave a comment

The Issue

If you tried to install to install psycopg2 package after upgrading to Mac OSX El Capitan and got an error like this:

xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), 
missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun

pip.log

The Soltuion:

Simplly install Command-Line Tools:

sudo xcode-select --install

Continue reading

CodeWars.com Can Improve Your Problem Solving Skill

Posted on Mon 05 October 2015 in Developer • Tagged with codeing, skills, problem solvingLeave a comment

Codewars logo

Recently I posted that your daily job can kill your skills, and I mentioned specifically the problem solving skill, as a software developer problem solving skill is one of the most important and key skill you need to master to be a good developer, in the post I mentioned that I started to solve code puzzles on CodeEval.com, it is good but during one of livecoding.tv session the developer mentioned CodeWars.com and I thought to give it a try, so I signed in and start to solve some puzzles aka katas and get higher in rank, and I discovered the differences and why CodeWars.com is better from my perspective.

CodeWars advantages

In CodeWars you’ll start to solve puzzles (it’s called kata) from starting rank (easy katas) toward much harder ones and this is common in code puzzles website, but what is special about CodeWars:

  1. Check others solutions: After post your solution you can view others solutions, and this can really help you in crafting the skill, for example you solved one kata and after you checked others solutions, you discovered better solutions “WOW these guys solved it in very clean way", and now you …
Continue reading

Solo Developer

Posted on Wed 08 July 2015 in Developer • Tagged with developer, programmingLeave a comment

Developers and coders are known as anti-social but after many years in development field, I can tell you this is totally wrong and developers who can communicate well are good developers they can learn and understand what they are really doing, if you read soft skills books for developers, sure you will find chapter about communications and How to be a part of software development team, but if you can’t communicate with your teammate you’ll always work lonely and gain nothing more than loneliness and coding in the dark.

Since I joined the software industry 4+ years, and I’m working, coding, and developing alone, I read about pair programming in XP “eXtreme Programming” and daily standup meetings in SCRUM, and How it can increase the quality and productivity of teams, but I didn’t experience those, I never pair programming and never being in one of Agile methodologies, but I’m trying to think with someone else not in the same team and not a developer, but it worth trying because it’s really amazing, you’ll feel like you have two extra minds, yes as you read it, it is like 1 + 1 = 3.

If you …

Continue reading

Initial Review: Becoming Steve Jobs

Posted on Mon 18 May 2015 in Review • Tagged with book, reviewLeave a comment

Becomming Steve Jobs book cover

Until now I finished 35% of Becoming Steve Jobs: The Evolution of a Reckless Upstart into a Visionary Leader book, and I don’t find Steve Jobs a successful entrepreneur or even a leader. Apple's first success because of Apple I which is Steve Wozniak idea and engineered by him as well, and Pixar was succeed because of its leader not Steve Jobs, in fact Steve Jobs was the reason for projects like (Apple III, Macintosh, and NeXT workstations) to fail, and was trying to make Pixar the next failure but its leaders keep him away and done what they knew it's right for Pixar. In the nutshell Steve Jobs is bad micromanager that you shouldn't dream to be like him, for me he is a fake leader.
I’ll continue the book to see How did he turn to be the visionary leader after that :)

Continue reading

Free Django hosting

Posted on Sun 19 April 2015 in Django • Tagged with django, pythonLeave a comment

If you developed Django application and want to deploy/publish it to the web you can check this list of Django friendly (http://djangofriendly.com/hosts/), but if you want a free hosting you can use Python Anywhere free hosting, I’m using it for my Django app and I’m very comfortable with but before using the free hosting please consider the following:

  1. They provide only MySQL for free hosting, so if you developed your app using PostgreSQL or SQLite, please download the correct driver.
  2. Application URL must be sub-domain of pythonanywhere.com, example my-app.pythonanywhere.com
  3. I’ll host one application only.
  4. No full access to a machine, you’ll deploy your application using console, use the console to install your virtual environment and packages, and edit some code using their in-browser code editor.

How to deploy?

  1. First go to this link and register your free account, then 
  2. Go to your dashboard, and select Consoles tab.
  3. Click on Python 2.7 (I personally still using python 2.7 but if you want select python 3.3) to open a new console.
  4. New console will open in your browser.
  5. Start by creating your virtualenv and install the required packages …
Continue reading

My First Django App

Posted on Mon 16 March 2015 in Django • Tagged with django, python, sideprojectLeave a comment

I'm starting to use Django and Python to develop web applications, I really love Django and during my learning process I thought I can build something while learning, and I had one idea keep it on hold as side project so I decided it's time to build it.

The Idea

Me and my wife have our financial system which is dividing the monthly budget into a weekly budget, most of us make budget on monthly basis because we get paid on monthly basis, but imagine your budget will be on weekly basis, it’s like every week is new budget and new start, and in order to keep track of the weekly budget you need to know how much you need to spend in a week. To be honest in the first we made a lot of mistakes but at the end we found out how much we need to spend weekly, and this need analysis with trial and error for at least one month then you will master your weekly budgeting.

Now the idea is build a system that can keep track of your payments or expenses against your estimated budget for a week. The application name is Ma3ana …

Continue reading

Virtual Environment

Posted on Sun 01 March 2015 in Python • Tagged with django, pip, python, virtualenvLeave a comment

While leaning web developing using Django and Python, I found out VirtualEnv or Virtual Environment is widely used, in first I didn't get it because I came from Microsoft .NET Framework development platform, so I thought of writing a post about it to make simple.

What is Virtual Environment?

VirtualEnv or Virtual Environment is a way to create isolated development environment each one has it's own packages and specific package version, for example VirEnv1 has Django 1.6 and VirEnv2 has Django 1.7, this isolation will keep your project packages dependency clear, isolated, and as I'll show you below that you can replicate the environment with one command and file, so if you work in team it's easy to share the same environment among the team.

virtualenv 1 virtualenv 2

How to install VirtualEnv?

VirtualEnv is a python package so to install is you need to install pip first.

  1. Open terminal and type the following command

    sudo apt-get install python-pip

  2. After finish installing pip type the following command to install virtual environment

    sudo pip install virtualenv

  3. After finish installing virtualenv, type the following command to create folder to store your virtual environments

    mkdir .virtualenvs

How to create virtualenv?

After install virtualenv you are …

Continue reading

Fictions for Developers

Posted on Thu 13 November 2014 in Developer • Tagged with developer, geekLeave a comment

blackhole

Tim Ferriss recommended in his 4-Hours Workweek book to read fiction books before sleep and this will help you disconnected from the real world and jump in book world which lead to better sleep.

Last Monday I went to watch the Interstellar movie with my wife and it was like reading fiction book before sleep, the movie is 3 hours long which is unique nowadays and full of science and psychics, but the story is full of fiction and the soundtracks are incredible. After we finished the movie I looked at my watch and WOW 3 hours passed and I felt like I was inside the movie and flying in the space, the time passed by and all my inner thoughts, to do lists, project plans, pending households, and life events are vanished and I’m totally inside the movie, in other words I’m totally disconnected from the real world. I felt fresh even though that it’s 12:00 AM and I have a work to go in the morning, but I felt fresh and my mind is clear and this give me chance to start my day so fresh, plus now I want to read more about …

Continue reading