tag:blogger.com,1999:blog-11788780.post113951297112235700..comments2023-12-29T13:22:33.104-08:00Comments on JJinuxLand: Python: Django Templatesjjinuxhttp://www.blogger.com/profile/03270879497119114175noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-11788780.post-20148150073022936272007-04-18T13:53:00.000-07:002007-04-18T13:53:00.000-07:00I don't think that's what he's saying... using a l...I don't think that's what he's saying... using a loop inside the view isn't repeating anything. You're just using the templating engine in a slightly different way. Instead of preparing all of your data, then making a single template call, make smaller template calls as you need them and string the whole thing together with a final render.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-11788780.post-1141165364788114012006-02-28T14:22:00.000-08:002006-02-28T14:22:00.000-08:00Quoted:I felt the same on my first contacts with t...Quoted:<BR/>I felt the same on my first contacts with those templates. But then I had an epiphany. Actually trying to develop with Django made me move all my logic out of the templates and into python (into the view), which is something I have been wanting to do for years.<BR/><BR/>I hear what you're saying, but I truly believe that even template authors should not be exempt from DRY.jjinuxhttps://www.blogger.com/profile/03270879497119114175noreply@blogger.comtag:blogger.com,1999:blog-11788780.post-1139529181623362492006-02-09T15:53:00.000-08:002006-02-09T15:53:00.000-08:00I agree with you Jason. I understand that the Dja...I agree with you Jason. I understand that the Django templates are meant to be simple so designers can understand them. But just the other day the designer I work with came to me because he wanted to use and OR with the ifequal tag. Django doesn't support this, so I submitted a <A HREF="http://code.djangoproject.com/ticket/1209" REL="nofollow">patch</A>. The resulting <A HREF="http://groups.google.com/group/django-developers/browse_thread/thread/a8ee0d9d3dafa023/2e09f63722226947?q=ifequal&rnum=1#2e09f63722226947" REL="nofollow">feedback</A> let me know that this was not wanted.<BR/><BR/>I thought about switching to Cheetah for a while, but I enjoy Django and I am still doing things the Django way.<BR/><BR/>However I have started to create my own library of custom tags that are more robust than the one Django offers.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-11788780.post-1139522830539289472006-02-09T14:07:00.000-08:002006-02-09T14:07:00.000-08:00Actually you can do that stuff quite easily with D...Actually you can do that stuff quite easily with Django - just produce some custom tags based on the inclusion tags stuff (like it is used in the admin). What this gives you essentially are template-based functions - only that they are written as tags.<BR/><BR/>Django does have a quite flexible template language - you only need to accept that to do more complex work, you either precompute stuff in the view function or build custom template tags.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-11788780.post-1139520595843072612006-02-09T13:29:00.000-08:002006-02-09T13:29:00.000-08:00Jason. I agree with you, although I'll probably u...Jason. I agree with you, although I'll probably use Cheetah instead. I *like* Myghty, but I've been using Cheetah for two years now. We have well over 100,000 lines of Cheetah company-wide, and I really like it.jjinuxhttps://www.blogger.com/profile/03270879497119114175noreply@blogger.comtag:blogger.com,1999:blog-11788780.post-1139519970812246882006-02-09T13:19:00.000-08:002006-02-09T13:19:00.000-08:00There is no requirement that you use the Django te...There is no requirement that you use the Django templates, though they are the "official" way that show up in all the docs (which is a good thing).<BR/><BR/>You might want to try using Myghty with Django... It looks like Myghty gives you the most freedom to define those functions in those templates like you want to. I say "looks like", though, because I haven't used, just skimmed the docs... If Myghty is "just a python library" like Cheetah is, then the integration of Django and Myghty might be pretty easy. So check out Myghty and let me know if I'm way wrong on this.Anonymousnoreply@blogger.com