What is “related_name” used for in Django

django related_name

related_name is an attribute you use while defining relations like many-to-one, many-to-many, one-to-one etc. The value of this attribute is used as the name of the reverse relation between models. Example:

Here we define a many-to-one relation using a

Read More What is “related_name” used for in Django

Python – Difference between “.append()” and “+= []”

In my new Django project, I was trying to append a list of tuples (which contained more than 1 tuple in it) into another list of tuples. Then I got this error: ValueError: too many values to unpack (expected 2) I

Read More Python – Difference between “.append()” and “+= []”

Django Error – django.db.utils.OperationalError: no such table

django-no-such-table

Django “no such table” error of death.. I recently encountered this “no such table” error while trying to run makemigrations command on PyCharm. I dropped database tables related to my app, cleaned django_migrations table for this app, cleared migrations folder as

Read More Django Error – django.db.utils.OperationalError: no such table

Difference between a Framework and a Library

difference-library-framework

Recently, I heard 2 of my friends talking about the difference between a framework and a library, and I thought some may need a clear explanation to see the difference. Check out the simple diagram below. Library A library is essentially

Read More Difference between a Framework and a Library

PyCharm – Django Debugger Won’t Stop At BreakPoints

pycharm django breakpoint

Debugging a Django project in PyCharm is actually quite easy. All you need to do is add couple of breakpoints and hit that little debug button you see at the top right corner of the IDE. Now when you run

Read More PyCharm – Django Debugger Won’t Stop At BreakPoints

Django – How to Clone a Virtual Environment

clone virtual environment django

I wanted to write 1 more post in 2016 before the year ends. So, here it is 🙂 Let’s talk a little more about Virtual Environments. If you have a virtual environment you can back it up and re-create it later

Read More Django – How to Clone a Virtual Environment

Cannot read property ‘toLowerCase’ of undefined

javascript error undefined

I am finally back with another post after a while. I had this time period where I got busy with other things in life and felt a little tired for coding and blogging. That seems to be over now. Thank

Read More Cannot read property ‘toLowerCase’ of undefined

How to perform an Ajax request in Django

ajax-in-django

Ajax request are everywhere in modern web applications. No matter which platform you are using for development, the main scheme is always the same. You send a request to a server side method using JavaScript, jQuery etc. and server processes

Read More How to perform an Ajax request in Django

Python – Single Line For Loops (List Comprehensions)

django-list-comprehensions

In Python there is a very simple and elegant way of defining a for loop in a single line. Thing is, not only can you define this for loop but you can also use the values in this loop to

Read More Python – Single Line For Loops (List Comprehensions)

Django – Adding a Form to Your Django Site

django-forms

In your Django website you have models. These models represent tables in your database. So, what would you do if you wanted to record new model data into your DB? How would you get user input? Of course, using forms.

Read More Django – Adding a Form to Your Django Site