On 6/10/07, Car <[EMAIL PROTECTED]> wrote:
>
>
> > Why not create it there? That is the moment you have all the data you
> > need and all you're doing is calling a constructor. The code you've
> > written there is a pretty normal pattern for taking form information and
> > putting it into a model.
>
> Because it forces me to make different view for each model.
> Its very difficult for novice to understand which logic should be
> placed in views, which on models.
> Is there a resource with django-patterns or good programming
> practices ?

What are the chances of those different views only containing minor
variations? If you find yourself duplicating (copy-paste) parts of a
view between views, then it's probably better for you to move oft
duplicated code into a function.

If you don't like putting Model instantiation and initialization in
your views, you can create a static method for each Model. For
example, see:

http://dpaste.com/11939/

which is based on your original code.

As for programming practices, look for the book "Python Programming
Patterns" by Thomas W. Christopher published by Prentice-Hall. I must
caution you though that most of the material there assumes at least
programming experience and at least some knowledge of Python.

For online resources, I find myself coming back to the "Charming
Python" series of articles on IBM developerWorks:

http://www.ibm.com/developerworks/search/searchResults.jsp?searchType=1&searchSite=dW&searchScope=dW&query=charming+python

HTH.
-- 
_nimrod_a_abing_

http://abing.gotdns.com/
http://www.preownedcar.com/

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to