django question
aerojunkemail at gmail.com
aerojunkemail at gmail.com
Tue Jan 7 14:53:45 EST 2014
Django is great
On Tuesday, January 7, 2014 12:55:07 AM UTC-7, CM wrote:
> On Monday, January 6, 2014 8:57:22 PM UTC-5, Roy Smith wrote:
>
>
>
> > Yes, exactly. There's nothing magic about a django view. It's just a
>
> > function which is passed an instance of HttpRequest (and possibly a few
>
> > other things, depending on your url mapping), and which is expected to
>
> > return an instance of HttpResponse. Within that framework, it can call
>
> > any other functions it wants.
>
> >
>
> > For example, http://legalipsum.com/ is a silly little site I built in
>
> > django. Here's the view for the home page:
>
>
>
> Nice!
>
>
>
> > Notice how the view knows nothing about generating the actual markov
>
> > text. That's in another module, which lives somewhere on my PYTHONPATH.
>
> > ALso, the view knows nothing about how the page is laid out; only the
>
> > templates know that. If I decided to redo this in tornado or flask,
>
> > whatever, I would need to rewrite my view, but there's not much to
>
> > rewrite. Most of the logic is in the Markov chainer, and that would
>
> > cary over to the new implementation unchanged.
>
> >
>
> > BTW, my suggestion to keep business logic and presentation code distinct
>
> > isn't unique to django, it's a good idea in pretty much all systems.
>
>
>
> Thanks for these points, helpful to see in practice. I'm trying to be
>
> more mindful of good coding practices, and this will be helpful as I continue
>
> to learn Django and making web applications generally.
More information about the Python-list
mailing list