Created
February 10, 2014 13:22
-
-
Save magopian/8915831 to your computer and use it in GitHub Desktop.
update from Django 1.4 to 1.5, various notes (not complete)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Not yet! But here are some notes (taken from the release notes): | |
## New | |
* use PBKDF2 for passwords | |
* new URL tags : remove all ```{% load url from future %}``` (and make sure there's no old style ```{% url %}``` tags lurking around) | |
* **INFO**: [update_fields](https://docs.djangoproject.com/en/dev/ref/models/instances/#specifying-which-fields-to-save) added to save only needed fields on a model | |
* **INFO**: calls to [call_command](https://docs.djangoproject.com/en/dev/ref/django-admin/#call-command) now propagates exceptions | |
* **INFO**: [LOGIN_URL](https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-LOGIN_URL) and [LOGIN_REDIRECT_URL](https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-LOGIN_REDIRECT_URL) settings now also allows view function names and named url patterns | |
* **INFO**: when using RequestContext, there's now a [perms](https://docs.djangoproject.com/en/dev/ref/templates/api/#django-contrib-auth-context-processors-auth) in the context that allows to do ```{% if 'someapp.someperm' in perms %}``` | |
* **INFO**: [multi-column indexes can now be created](https://docs.djangoproject.com/en/dev/ref/models/options/#django.db.models.Options.index_together) | |
* admin commands should not use ```print``` anymore but [sys.stdout.write and sys.stderr.write](https://docs.djangoproject.com/en/dev/howto/custom-management-commands/#management-commands-output) | |
## Backwards incompatible changes | |
* python >= 2.6.5 | |
* https://docs.djangoproject.com/en/dev/internals/deprecation/#id2 | |
* [no more 'params' in TemplateView context](https://docs.djangoproject.com/en/dev/releases/1.5-beta-1/#context-in-templateview) | |
* [SimpleJson not used anymore](https://docs.djangoproject.com/en/dev/releases/1.5-beta-1/#system-version-of-simplejson-no-longer-used) : use ```json``` instead (available in py26) | |
* [(previous|next)_page_number now raises InvalidPage exception](https://docs.djangoproject.com/en/dev/releases/1.5-beta-1/#validation-of-previous-page-number-and-next-page-number) | |
* [changes in test execution](https://docs.djangoproject.com/en/dev/releases/1.5-beta-1/#changes-in-tests-execution) : make sure tests still run as expected | |
* [slugify now available as django.utils.text.slugify](https://docs.djangoproject.com/en/dev/ref/utils/#django.utils.text.slugify) | |
## Deprecations | |
* [streaming behavior of HttpResponse changed](https://docs.djangoproject.com/en/dev/releases/1.5-beta-1/#streaming-behavior-of-httpresponse) | |
* [django.contrib.markup](https://docs.djangoproject.com/en/dev/releases/1.5-beta-1/#django-utils-markup) | |
* [django admin command cleanup replaced by clearsessions](https://docs.djangoproject.com/en/dev/releases/1.5-beta-1/#cleanup-management-command) | |
* [no more depth parameter in select_related](https://docs.djangoproject.com/en/dev/releases/1.5-beta-1/#depth-keyword-argument-in-select-related) | |
## Configurable user model | |
[configurable user model](https://docs.djangoproject.com/en/dev/topics/auth/#auth-custom-user) | |
### Switch from auth.User proxy to custom User | |
* remove "Proxy" from the User meta class, custom User herits from ```django.contrib.auth.models.AbstractUser``` (and not from User anymore) | |
* remove the line ```admin.site.unregister(User)``` | |
* create schema migration to rename table ```auth_user``` to ```custom_user``` and all other "through" tables for M2M to User (*), and columns for those tables (user_id => custom_user_id) | |
* add ```AUTH_USER_MODEL = 'custom.User'``` to settings | |
(*) to find the models with a M2M relation to the User: | |
``` | |
u = User.objects.all()[0] | |
for f in dir(u): | |
try: | |
attr = getattr(u, f) | |
except: | |
continue | |
if hasattr(attr, 'through'): | |
print f, attr.model | |
groups <class 'django.contrib.auth.models.Group'> | |
user_permissions <class 'django.contrib.auth.models.Permission'> | |
``` | |
### Merge UserProfile into custom User: | |
* *add UserProfile's fields to custom User | |
* create schema migration for the added fields in custom User | |
* create data migration to copy UserProfile fields to custom User new fields | |
* create schema migration to remove UserProfile | |
* UserProfile's methods to custom User | |
* UserProfile's ```save()``` method to custom User | |
* fix fixtures (replace ```auth.user``` by ```custom.user```) | |
* [remove AUTH_PROFILE_MODULE setting](https://docs.djangoproject.com/en/dev/releases/1.5-beta-1/#auth-profile-module) | |
* replace all occurences of ```get_profile()```, ```profile__```, ```__profile``` and ```UserProfile``` | |
* replace all foreign keys to User to be on settings.AUTH_USER_MODEL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment