see comments inline... On 5/5/08, phillc <[EMAIL PROTECTED]> wrote: > > there has been a few things that i feel have been holding back from > making my code structure/process better. i was hoping someone could > help me on some of these questions. > > first: > ==== > How does one develop tests for django web apps? > im having trouble writing tests. > i understand there are view tests, but those are so overly complex to > write. > i was just wondering how other people approach it, and if anyone can > point me to some open source application that uses tests properly. > i would love to give test driven development a try, but right now, i > feel that my code is too bound to code in my view, which im having > trouble making unit tests for. (id love to see a django project > somewhere that was test driven) >
My tests are pretty much limited to model functions, I do not test a great deal of my view logic. Just my preference. > second: > ==== > i have a model object, that "has many" of another object, which "has > many" of another object. (relations) > i want to display each in groups based on their parents > which is better design? > pass the top most parent to the template, and have the template go > through each of the top obect then each of the next object > =or= > have the view do it and pass it to the template > > I do as much of this as possible within my model, ie I have a number of models with a self join "parent" All of those models have a recusive function called get_children that can provide me with all of the children and grandchildren, etc... > third: > ==== > in the same situation, where i have several relations > i want to save data, (say i was unable to use model forms) > my forms allow input of the parent, and each of the children model > objects. > is it better to put my save logic in the new form object, or in the > model? > if you say new form object, is there ever a time that you would put > all of your saving logic in the model instead of the form? > > I put any and all model required save logic within the model. My perspective is that if it is of a fundamental nature to the data, it goes in the model, if it is simply fundamental to a specific view or form, I will put it there. > fourth: > ==== > i never understood this, why do people do > > somevar = "blah blah %s" % anothervar > > instead of "blah bla" + anothervar > ? > > fifth: > ==== > in my models, a model object is only aware of the objects above it, > and not below it. > in C, i remember i just declared all functions, with no body to it, at > the top of the file > then all functions were aware of all functions. > how do i do this in python? > > > thanks a ton for your input =) > > > --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---