Sorry for the previous one, accidentally pressed alt-s What I meant to say was: as far as I can see your problem is mostly covered by faulty db-design or maintenance, which is not something django should cover in my opinion, it seems logically you do a cleaning of your database to set all non-existing foreignkeys to NULL.
2009/2/22 Killian <killia...@gmail.com> > Hi > > 2009/2/21 Adys <adys...@gmail.com> > >> >> Hi there >> >> I've been thinking for the past couple of days of a simple "lazy" >> ForeignKey design (or whichever name would fit better). It's something >> I've tried really hard to find in Django, unsuccessfully. Some >> explanation first... >> > Lazy is imho not a decent name indeed, 'lazy' usually means relationships > aren't fetched prematurely (foreignkey object isn't fetched automatically), > which django does by default if I'm not mistaken. > >> >> I tried to get some background on django-users, cf >> http://groups.google.com/group/django-users/browse_thread >> >> /thread/caec53feb0ddb43a# >> To make it short: My project reuses imported data. This data is *very* >> faulty and a lot of ForeignKeys point to deleted/non-existing rows. I >> can't afford checking integrity constantly (cf link). >> > As far I c > >> >> A lazy ForeignKey would assume the data is valid, and return >> "something else" if it's not. I'm not sure what the best value >> returned would be. It could be a row with placeholder/default values, >> it could be an exception, etc. I haven't worked deeply with Django's >> codebase, I'm unsure about design details. >> The idea here is to be able to offer something "valid or unknown". I >> hope I'm not too unclear... >> > First of all, imho this isn't about "lazy", lazy usually means > relationships aren't fetched prematurely (foreignkey object isn't fetched > automatically), which django does by default. > > Secondly, the NULL value in databases is actually defined originally as > Unknown, so it seams normal in your situation to default to None if your > relationship is undefined (and allow null=True in your model). > >> >> I'm sure there's a better solution - I have yet to find it - but I >> would first like to hear feedback on a feature like that. If you feel >> it's a good idea I'm interested in working on it. If you feel >> otherwise, well... I'm still looking for a better suggestion. >> >> Cheers >> >> JL >> >> >> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@googlegroups.com To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-developers?hl=en -~----------~----~----~----~------~----~------~--~---