summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2013-06-17 15:47:44 (GMT)
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2013-06-17 15:48:25 (GMT)
commit430c1b3e82373f5b8bbf82596b7a100244d8a28c (patch)
tree7c34061d4d1dad3e5f3ec9ecd9e9349bbf721ab7 /doc
parent3edfac8e1eb9272c9ec5f689d2aa4dc61d2e606a (diff)
downloadauthentic-430c1b3e82373f5b8bbf82596b7a100244d8a28c.zip
authentic-430c1b3e82373f5b8bbf82596b7a100244d8a28c.tar.gz
authentic-430c1b3e82373f5b8bbf82596b7a100244d8a28c.tar.bz2
add documentation on how to write migration working with a custom user model
Diffstat (limited to 'doc')
-rw-r--r--doc/developppers_faq.rst37
1 files changed, 37 insertions, 0 deletions
diff --git a/doc/developppers_faq.rst b/doc/developppers_faq.rst
new file mode 100644
index 0000000..d4dea1f
--- /dev/null
+++ b/doc/developppers_faq.rst
@@ -0,0 +1,37 @@
+Writing migrations
+==================
+
+Migration containing reference to the user model must be rewritten manually to
+refer to the user model name indirectly. The followind modifications must be applied.
+
+1. First import the `user_model_label` from the `authentic2.compat` module:::
+
+ from authentic2.compat import user_model_label
+
+Any reference to `orm['auth.User']` or `orm['authentic2.User']` must be
+rewritten into `orm[user_model_label]`. For example this line:::
+
+ ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['authentic2.User'])),
+
+must be changed to:::
+
+ ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm[user_model_label])),
+
+2. The user model when appearing in the `models` field like this:::
+
+ u'auth.user': {
+ 'meta': {'object_name': 'User',
+
+must be rewritten like that:::
+
+ user_model_label: {
+ 'Meta': {'object_name': user_model_label.split('.')[-1]},
+
+3. If the user model is referred inside the `to` field of a foreign key
+ declaration like this:::
+
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['auth.User']"})
+
+ must be rewritten like that:::
+
+ 'user': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['%s']" user_model_label})