4
4
4yBa4oK2014-12-10 18:29:58
Django
4yBa4oK, 2014-12-10 18:29:58

What is the Django difference between different versions of python?

all examples will be on python 2.7, but I want to write on the 3rd
also please advise good documentation

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bromzh, 2014-12-10
@bromzh

There will (probably) be problems with Unicode. For example, for model names in 2.7, you need to overload __unicode__, and in 3rd - __str__. Well, do not forget that http will send everything in a single-byte encoding, which in the 3rd python is designated as the bytes type, not str. Therefore, sometimes you have to do decode.
For example, in the flask in the 3rd branch, the test client saves data in the response object as bytes, and JSON can only work with strings (which are now only Unicode in the 3rd branch). Needs to be decoded. Although in the framework itself (not in the test client) you do not need to do this, it decodes itself as it should.
Well, read the main differences between the branches: print is now a function, the dictionary methods iteritems, iterkeys, itervalues ​​are abolished, since iterators are now used by default (only items, keys, values ​​remain). Some libs (including urllib) have changed the structure, so some modules will need to be imported differently. Well, and so on.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question