On Fri, Jul 31, 2009 at 8:53 AM, Fleg <francois.legr...@gmail.com> wrote:
> > Yes, I saw this case and that's what I need... > The point is that the proposed fix implies to patch the django core > which I would prefer to avoid. > The other solution need to add as many lines of code as you have > associated objects (and for all objects)... which is quite heavy (if > you add a foreign key to your table you need to update the model > definition + the reload method...). > F. > I wasn't suggesting you use the proposed fix: it's four years old and the Django code in question has undergone substantial changes (django/core/meta no longer exists) so it isn't directly applicable any more anyway. Implementing the workaround doesn't require changing your reload method every time you change your model. The particular use case in the ticket involved only one attribute that needed to be re-loaded, so it was easiest to just re-assign that attribute. If you have many (or potentially all) fields that need to be reloaded there is no reason you can't use the field information contained in the model's _meta.fields list to do a more wholesale "reload" that doesn't rely on knowing what attributes, specifically, need to be re-assigned. Essentially you probably want to implement the code that would be placed in Django core if this were to be supported by Django, only in your own code. You'll have to dig into some of the model internals probably to figure out how to do it, but I don't think it is that hard. Relying on internals means it could break if they change in the future but I think you'd only need to use some basic stuff that is unlikely to change at this point. Karen --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---