|Version 2 (modified by 11 years ago) (diff),|
Removing the magic: the cheat sheet
Work in progress.
This document assumes a basic familiarity with Removing the magic changes. It is designed to be used as a simple cheat sheet during a conversion process providing links to relevant parts Removing the magic document. It is organized by functional areas: databases, settings, models, views, templates, and template tags. This document doesn't cover new functionality.
Optional (saves time): if your project doesn't have
manage.py file in the project's directory, copy it from
Database changes are covered extensively in Database changes you'll need to make. Just execute appropriate SQL scripts.
Optional (saves space):
package column of
auth_permission table is not used anymore. You can drop it by executing following SQL statement (works for MySQL):
ALTER TABLE `auth_permission` DROP COLUMN `package`;
Eugene's note: after conversion I found that my permissions are screwed up. I regenerated them this way:
- Delete a content of following tables (you can do it now):
- After you finished with code changes, run
manage.py syncdb. Don't do it now'''
It repopulates the content of said tables properly, but an administrator has to reassign group and user permissions again in Admin. Obviously it can be a problem, if you have hundreds of users with arcane permissions.
- If your applications still live in
yourproject/apps/directory, you can move them up one level: move
- Relocate models by moving content of files in your
- If your models use
dbmodules without exporting them directly, add import statements.
- Relocate Model and Field classes: use
- Convert the META.admin member to new inner
class Adminof the model. Don't forget to remove all pesky commas at the end of lines.
- Remove from META following parameters:
admin(see the previous step),
where_constraints. If now your
class METAis empty, delete it. Otherwise rename it to
- Replace __repr__ with __str__.
- If you use
_post_delete()hooks, replace them by overriding
If you decided to regenerate permissions, now is the good time to execute
django-admin.py syncdb or
manage.py syncdb. Remember that an administrator should reassign permissions to all users using Admin.