Most beginners with django framework make the mistake of revealing sensitive information in their settings module especially when deploying to a version control (most popularly, GitHub.) this however creates serious security issues when the the site eventually goes live! The most common victim of this is the SECRET_KEY and others including database password and API keys which when allowed to the eyes of the public defeats most of django’s security measures. If you’ve already made this mistake, it is strongly advised you change your key before deploying your site to production. Here are the various methods to keep your SECRET_KEY and other sensitive information out of the public
Read More
Thursday, 23 November 2017
Monday, 19 September 2016
Django: Difference between BLANK and NULL model attributes
At some point in my experience with django web framework, i have been puzzled as regards the meaning / difference between the above model attributes. Here is a pretty nice explanation for them:
NULL: setting the null attribute of a django model to True allows that particular field to save empty values as null in your database. null is a database terminology that represents a missing value. It is very different from a zero or a space value, it is just the database word for empty.(consult an SQL textbook for more explanation). The null attribute works on the database level and has nothing to do with form validation.The default value is False.
BLANK: django uses your model classes to perform different abstractions which include automatically creating forms to feed data to your database where needed. setting blank = true allows any of these forms to be left blank. setting it to False makes it a required field hence raises an error on the form when left blank.
As the official docs has it:
So when and how do i use blank=True or Null=True?
use blank=True when you want a user to continue his/her action without filling a form, vice versa.
use null=False when you don't want an a null value in your database irrespective how. However, Both attribute can be combined in some cases.
(blank=True, null=False) will raise an integrity error if the field is left blank.(TextField and CharField sends an empty string as value instead).
(blank=False, null=True) forbids the form from being empty but allows a null value in database if set manually through raw sql code or any other means.
I hope this helps.
Read More
NULL: setting the null attribute of a django model to True allows that particular field to save empty values as null in your database. null is a database terminology that represents a missing value. It is very different from a zero or a space value, it is just the database word for empty.(consult an SQL textbook for more explanation). The null attribute works on the database level and has nothing to do with form validation.The default value is False.
BLANK: django uses your model classes to perform different abstractions which include automatically creating forms to feed data to your database where needed. setting blank = true allows any of these forms to be left blank. setting it to False makes it a required field hence raises an error on the form when left blank.
As the official docs has it:
Note that this is different than null. null is purely database-related, whereas blank is validation-related. If a field has blank=True, form validation will allow entry of an empty value. If a field has blank=False, the field will be required.the default value is False.
So when and how do i use blank=True or Null=True?
use blank=True when you want a user to continue his/her action without filling a form, vice versa.
use null=False when you don't want an a null value in your database irrespective how. However, Both attribute can be combined in some cases.
(blank=True, null=False) will raise an integrity error if the field is left blank.(TextField and CharField sends an empty string as value instead).
(blank=False, null=True) forbids the form from being empty but allows a null value in database if set manually through raw sql code or any other means.
I hope this helps.
Friday, 5 August 2016
How To Install SublimeText plugins
Sublime Text is a proprietary cross-platform source code editor with a Python application programming interface. it has been my favorite IDE, mostly due to its lightweight, powerful and yet available for all major platforms. it is also notable for its extensive ecosystem of plugins which means that once you have downloaded the editor, you can install plug-ins for adding more features to it. This tutorial aims at showing you how to access the various extensions available to sublimeText.
The most important tool of all is the Package Control, which is the manager for installing additional plugins directly from within Sublime. This can be done manually or by copying and pasting the appropriate python code in your sublime console. The second is the most recommended method. It will take care of the rest of the package installation ahead.
To install package control, visit the package control installation page, find and copy the code relevant to your version of sublime, open your sublime console with ctr+` and paste the given code.(endeavour to have internet connection.) then wait for the command to execute.
If for any reason the above method fails, you can go through the manual method by:
Read More
The most important tool of all is the Package Control, which is the manager for installing additional plugins directly from within Sublime. This can be done manually or by copying and pasting the appropriate python code in your sublime console. The second is the most recommended method. It will take care of the rest of the package installation ahead.
To install package control, visit the package control installation page, find and copy the code relevant to your version of sublime, open your sublime console with ctr+` and paste the given code.(endeavour to have internet connection.) then wait for the command to execute.
If for any reason the above method fails, you can go through the manual method by:
- Launch sublime text
- On the option menu, navigate to preferences > Browse packages
- A dialog box will pop up, then move the folder one step backwards where you'll find the installed package folder
- Download package control and copy it into the Installed package directory
- Restart sublime Text(close and re-open)
Monday, 1 August 2016
Transferring files between pc and android devices using flash share
I was having a faulty USB port and needed to transfer files quickly to my pc from an android device faster than bluetooth and my curiosity led me to this.
If you've ever used an android smartphone, you should be familiar with flash share and its likes that makes it possible to transfer files between different android devices at incredible speed by utilizing the inbuilt wifi connection compared to it's much slower predecessor, bluetooth. It is possible to do the same from android to pc without going through the hurdles of USB or the sluggish bluetooth connection following the steps below:
Read More
If you've ever used an android smartphone, you should be familiar with flash share and its likes that makes it possible to transfer files between different android devices at incredible speed by utilizing the inbuilt wifi connection compared to it's much slower predecessor, bluetooth. It is possible to do the same from android to pc without going through the hurdles of USB or the sluggish bluetooth connection following the steps below:
- Download and install flash share on your android device(available on playstore),
- Install any hotspotting software on your PC(i used OSToto hotspot)
- Connect your android to the network.
- Open your flash share and navigate to 'connect to pc',
- Open your web browser and navigate to the i.p address shown
- Enter the passcode in the dialog box shown on your browser
- you now have a web interface file manager for your android device! see screenshots below
Monday, 9 May 2016
How To Learn Programming
Programming is an art , whose concept may seems bizarre to newbies or non-techies. However, taking time to study these concepts makes one realise that mastering programming is as easy as learning every other trivia art. But following the principles explained below reduces the learning curve and makes your journey to becoming a programmer a fun filled one.
1. DECIDE YOU WANT TO LEARN HOW TO PROGRAM
This principle
applies to all forms of learning. You would do better if you’re learning
something you have passion for. focus
your attention on learning rather than ‘how do I make money from this’. In a
nutshell, passion should be your drive not income.
2. CHOOSE A LANGUAGE TO START WITH AND FOCUS ON IT
Now that you have decided to learn to program, you should
decide on a language you’re to start with. Trying to learn multiple languages
at the same time is an easy route to confusion. Eliminate yourself from
language wars at this stage, every language has its good and bad sides so
ignore comments as to which language is better than the other. After
successfully understanding a particular language, you’ll realize that programming
concepts are similar in all language, just a few syntax changes. Hence,
learning a new language after your first will be a walkover.
3.START WITH THE BASICS
Don’t be in a hurry to learn programming. You should start
out with the basic ‘hello world’ program Don’t find it as too cheap or trivia
no matter your age. Embrace books with titles such as ‘…for kids’,…for
dummies’, books such as these usually turn out to be the best for learning as
they explain in simpler terms and assume you have zero knowledge about
everything. Don’t compare yourself who’s just starting to program with those
that have started coding since the days of assembly language. With time, you’ll
get there!
4. ‘CODING ALL DAY KEEP D BUGS AWAY’
Do not be discouraged by bugs appearing in your code. Infact
as a programmer, you’ll spend more of
your time debugging your codes than actually writing them. It is nearly
impossible even for experienced programmers
to write 20 lines of code without
a single bug . However, constant
practice, the number of bugs you ecounter tends to reduce.
5. JOIN PROGRAMMING COMMUNITIES
It can be frustrating trying to figure out how to do things
all by yourself. Join an active coding community you can run to for help when
you ecounter problems, learn how to effectively make use of search engines to
figure out solutions for yourself
6. BUILD SOMETHING USEFUL
Now that you have mastered the language of your choice, it
is time to make use of your newly acquired knowledge to build a real life
application. At this stage, reinventing the wheel is totally allowed when
necessary. The purpose of this is simply to ensure you can put your knowledge
into use which is the overall aim of learning to code
7. LEARN A NEW LANGUAGE
Now that you’ve mastered your first programming, it is
advisable to pick up a new language and begin the cycle again. This helps to broaden your horizon and
gives you a clearer picture of some programming concepts
Thursday, 7 January 2016
Solution to Tcl error: favicon . ico is not defined when setting windows icon in tkinter
Most gui programmers using the standard tkinter framework has ecountered this error at least once when trying to change the ugly looking red tkinter default icon. I had my share recently and tried to trace the error for days without success and even nearly ported my program to another framework before I arrived at a solution.
Think python - Book review
Being a newbie in programming, the first book that caught my fancy was Think python - How to think like a computer scientist by
Allen B. Downey.
The book introduces you to programming in general starting from basic
concepts including variables, operators, expressions and statements
before delving into python programming in full.
Read More