Encapsulating Complex Business Logic in a Migraiton

2017-08-29 Thread Matt S
Standard practice is that you do not refer to "current" models (i.e. from 
app.models import MyModel) in a migration as the migration will break when 
that models changes. This means copying any model-specific code into the 
migration. This becomes impractical when the code needed for the migration 
spans multiple files and models.

How can I encapsulate a complex chain of business logic involving multiple 
models in a migration? For example, if I have instance methods on ModelA 
which calls methods on ModelB, ModelB queries for ModelC and calls methods 
on it. If I use those methods as they exist on the models, the migration 
will eventually break when any of the involved Models' schema changes.

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


django.contrib.admin.util.quote does not handle spaces (%20 -> _20)

2009-06-05 Thread Matt S.

I have a primary key that allows spaces, e.g., "foo bar", which comes
up in the admin list page properly, but the
URL becomes "http://example.com/admin/myapp/mymodel/foo%20bar/; when I
expect it to become "http://example.com/admin/myapp/mymodel/
foo_20bar/".  If you follow the link you'll get a debug page with:

"""
Page not found (404)
Request Method: GET
Request URL:http://example.com/admin/myapp/mymodel/foo%20bar/

mymodel object with primary key u'foo%20bar' does not exist.
"""

It seems that django.contrib.admin.util.quote should convert spaces
along with the other characters it already does.

I can submit a patch, but is there anyone else that's had this problem
or any concerns about backwards compatibility?  Thanks.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---