Disrespect is t…

Disrespect is the greatest relationship destroyer.
Disrespect is never forgotten and not easily forgiven.
The easiest way to destroy a relationship is to show disrespect to someone.One act of disrespect is sufficient for a relationship to break forever.We don’t have a mechanism to handle disrespect.
Depending on the situation and the power of the other person we either fight back or withdraw or avoid.
Disrespect is an act of violence.

Important Passage from “frozen thoughts” magazine


Quote | Posted on by | Tagged , | Leave a comment

Django Template Internals

Welcome and My gratitude for your patience and time.

After a long time came to write by cut off 1 episode of prison break.

Yesterday in my office we had a short discussion about django template system. Thanks to @shanmuganandhg and @rosarioarun

Template system Basics

Django template is one of the important component in django. Here We are not covering about Django template basics. But,we direct you here  https://docs.djangoproject.com/en/dev/topics/templates

Straight to the topic,

Once we got request, we process it, eventually response will be returned. So, mostly we use render_to_response shortcut method to return response in django views.


from django.shortcuts import render_to_response

return render_to_response(template, {}, context_instance=RequestContext(request))

digging render_to_response,

It takes three arguments(2 positional + 1 keyword arg),

1.template name 2. dictionary 3. RequestContext (optional).

The RequestContext is important when you need meta information in application like session key, login credentials etc..

render_to_response does nothing except calling render_to_string, so,

digging render_to_string,

It takes three arguments(2 positional + 1 keyword arg),

1.template name 2. dictionary 3. RequestContext (optional).

It is loading the template from loaders using the function called “find_template”

There are different type of template loaders are there.

loading from filesystem( ‘django.template.loaders.filesystem.Loader’,)

loading from cache etc…

you can write your own custom loader too.

How template content loading from loader?

It fetches the template loaders which defined at settings.TEMPLATE_LOADERS and passing the template name to the each loaders, finally receives the template content


 in this above attached image(taken from django source code) variable source is just template content in string format.

Now you got the template content as basestring. Here after compilation and rendering steps are there.

Get the template content as compiled.


t = Template(*args, **kwargs)

The template class is used to compile the raw template content with some functionalities.

Ok. So, What is happening in the Template class?


lexical analysis:                     

lexer = lexer_class(template_string, origin)


parser = parser_class(lexer.tokenize())

nodelist = parser.parse()

then returning the compiled template object.

rendering the compiled template with context dictionary

The compiled template which is splitted by token and parsing the tokens finally returning the evaluated tokens to be renders as html


Sample Workflow:

from django.template.base import Lexer,Parser

>>>template_string = """<html><title>
{% if flag %}
 Welcome to Python!!! 
{% else %} 
 Welcome to Django!! 
{% endif %}

>>>lexical_token = Lexer(template_string,{})
>>>print lexical_token
<django.template.base.Lexer at 0xabcb30c>

#parsing the nodes
>>>parser = Parser(lexical_token.tokenize())
>>>parsed = parser.parse()
>>>print parsed
[<Text Node: '<html><title>'>, <IfNode>, <Text Node: '</title></html>'>]

#Template is compiled,It is about to render now


TypeError Traceback (most recent call last)
/usr/local/lib/python2.7/dist-packages/django/core/management/commands/shell.pyc in <module>()
—-> 1 parsed.render()

>>>context = {}
#Rendered with else condition
 u'<html><title> Welcome to Django!! </title></html>'

>>>context = {"flag":True}
#Rendered with if condition
u'<html><title>Welcome to Python!!! </title></html>'

Post your views as comments. Sharing is learning !!

Posted in Django, template | Tagged , , , | 1 Comment

where we have to use ‘through’ in django many-to-many model field?

where we have to use ‘through’ in django many-to-many model field?

In django the many-to-many field used to have multiple relationships with referred and used models

In generally, if you use many-to-many field django automatically creates a intermediate table

suppose, for your mighty usecase, you want to add some additional fields in that intermediate table

you can go proceed with the ‘through‘ feature


refer-doc link https://docs.djangoproject.com/en/dev/topics/db/models/#intermediary-manytomany

In the above attached image, the Membership class contains the additional fields like date_joined,invite_reason available as I explained above

Without using this special feature, if you do the adding extra fields(date_joined,invite_reason) in the Group class itself,

you can have the field for the each group object like


but not like this




To obtain this usecase we have to go with ‘through‘ attribute feature as availble in the diagram

Posted in Academic, Django | Tagged , , | Leave a comment

Points to remember before computing large data problem

Got the seminar from @shanmuganandhg

1. What is the size of data?
2. What is your ram size?
3. Will the data fit into your ram?
4. So, If you need to run the analysis for the streaming data,everytime will you do the computation for the whole amount of data(sequential logic) or else
storing the computed state into memory(combinational logic) and processing from it for the streaming data?

After took the decision from the fourth question

5.Think about How to be implemented For example, In python(consider main memory,low data size) or postgres(table,large data size)


If you want to do sequential logic you can also think about colocation of the data(grouping the data).This will make the job simpler.

Posted in General_Tech, Prob_system | Leave a comment

Prepaid Mobile Recharge Error, Go with Django

It was an urgent to me for recharging the amount in mobile.when I was doing with hurry,the app frustrates me

I filled all blank fields and it asked me for the confirmation also.


When i clicked the confirm button it throws me


I think they have done in struts

It frustrates the customer isn’t?

better they can move to Django to avoid these kind of frustrating problem to make unfriendly with customer.



Posted in Free Software, Problems | Tagged | 3 Comments

Great Answer in Quora

Technologies don’t matter. 

Programmers like to talk about technology. Is Ruby better than Python? Which RPC layer is faster? Should Facebook use Python and not PHP? This is great, and you should know and have opinions about those facts (especially if you’ve followed the latter advice). But quite surprisingly, if you look at successful and unsuccessful engineering efforts, there is essentially no correlation between success and the exact types of technologies that are used. What matters is who is working on a team, how they use the technologies, and how they work together. Good software engineering is done by good software engineers. It’s rarely done with the perfect programming language, or the preferred operating system, or using the most hyped new technology. A lot of the hardest challenges in software development concern the way people communicate and work together, not in raw technology.

There are many important corollaries to this: Pick programming languages you or your team use well, or are aligned with the market, or are popular enough you can hire folks. Be pragmatic, not religious about how you solve problems. Learn by working with great engineers, and seeing how they solve problems, not by preferring a particular approach. Realize that effective communication and good engineering culture are even more important than powerful tools

Source : http://www.quora.com/Computer-Programming/Expert-hackers-What-are-your-top-three-insights-for-a-novice-programmer


Good to follow it :-)

Posted in Academic, Problems, Sense | Leave a comment

Python debug

Python Debugger:

Recently i came to know that The most important things to be a Great programmer,not only to know the programming..knowing the debugging is makes this as a great programmer from quora and swaroop

So,Certainly I was searching about debugging in python.

>>>import pdb

python debugger package to debug your python gold code.


This line you need to add where you want to start debugging.

Absolutely we can debug

>>>pdb.run(“string function object”)//function object as a string

There are pretty lot of options and commands are there to do debugging.

The debugging shell looks like

> /work/t/rec.py(12)recursive_fn()
-> return
(Pdb) args
n = 3
output = to print

The command options in the debugging shell:


list the lines where the current call stack is processing


Next line to be debugged


These are the commands which does the operation according to it’s meaning.

p var

print var(var means variable)

p var1,var2,var2

pp var

pprint variables by comma seperator


current call stack

If you want assign a value for a variable in the debugging shell

You have to use the (!) exclamatory mark

!var = value

These won’t throw exception related to object

These are the basic skills i touched today

If you need elaborately go ahead with these


Posted in General | Leave a comment