Re: [Django] #25771: Serialization of natural foreign key in migration scripts does not work

2015-11-20 Thread Django
#25771: Serialization of natural foreign key in migration scripts does not work
-+-
 Reporter:  bowensong|Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Uncategorized|  Version:  1.8
 Severity:  Normal   |   Resolution:  invalid
 Keywords:  database migration   | Triage Stage:
  serialization  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by bowensong):

 Replying to [comment:4 timgraham]:
 > Maybe you can define the `natural_key()` method in the migration and
 then add it to the model retrieved from the apps registry:
 > {{{
 > def natural_key(self):
 > ...
 >
 > Teacher = apps.get_model("mytest", "Teacher")
 > Teacher.natural_key = natural_key
 > }}}

 Thanks, this works perfect.

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.2be0a9d3512f293e16deedfa848bb5b6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25771: Serialization of natural foreign key in migration scripts does not work

2015-11-20 Thread Django
#25771: Serialization of natural foreign key in migration scripts does not work
-+-
 Reporter:  bowensong|Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Uncategorized|  Version:  1.8
 Severity:  Normal   |   Resolution:  invalid
 Keywords:  database migration   | Triage Stage:
  serialization  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by timgraham):

 Maybe you can define the `natural_key()` method in the migration and then
 add it to the model retrieved from the apps registry:
 {{{
 def natural_key(self):
 ...

 Teacher = apps.get_model("mytest", "Teacher")
 Teacher.natural_key = natural_key
 }}}

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.92a8f934be1aa9ce56cb920164ad9700%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25771: Serialization of natural foreign key in migration scripts does not work

2015-11-20 Thread Django
#25771: Serialization of natural foreign key in migration scripts does not work
-+-
 Reporter:  bowensong|Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Uncategorized|  Version:  1.8
 Severity:  Normal   |   Resolution:  invalid
 Keywords:  database migration   | Triage Stage:
  serialization  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by bowensong):

 OK, my problem was because I'm using the elasticsearch
 ([https://www.elastic.co/products/elasticsearch]), and elasticsearch uses
 JSON format.
 In the normal use case, elasticsearch being updated by the `post_save`
 signal, but in the event of data migration, the `post_save` function is
 not being called. In that case, I have to do the elasticsearch update in
 the migration script, and this didn't work because the natural key issue,
 I got wrong (unexpected) data in the JSON.
 If you are not going to fix it, would you able to provide any suggestions
 about how to do this in a correct way?

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.222b17771cffa7e05f17c8ee4144ca01%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25771: Serialization of natural foreign key in migration scripts does not work

2015-11-19 Thread Django
#25771: Serialization of natural foreign key in migration scripts does not work
-+-
 Reporter:  bowensong|Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Uncategorized|  Version:  1.8
 Severity:  Normal   |   Resolution:  invalid
 Keywords:  database migration   | Triage Stage:
  serialization  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 I thought about calling this out in the docs, but I'm not convinced that
 doing serialization in migrations is a common use case or something that
 we should promote (see #24778 for discussion).

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.cad58daf94d73ad617e5edd87ff89646%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #25771: Serialization of natural foreign key in migration scripts does not work

2015-11-18 Thread Django
#25771: Serialization of natural foreign key in migration scripts does not work
-+-
 Reporter:  bowensong|Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Uncategorized|  Version:  1.8
 Severity:  Normal   |   Resolution:
 Keywords:  database migration   | Triage Stage:
  serialization  |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 I think this is expected behavior because the `natural_key()` method isn't
 available in migrations. Per
 [https://docs.djangoproject.com/en/dev/topics/migrations/#historical-
 models the docs], "Because it’s impossible to serialize arbitrary Python
 code, these historical models will not have any custom methods that you
 have defined."

--
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.b10c200d4cd26fea10d2f233372f9268%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.