On Tue, Mar 31, 2009 at 12:35 PM, Dotan Cohen <dotanco...@gmail.com> wrote:

>
> > Dotan, I think once you've got your head around some of the key concepts
> > (urls, models, template inheritance and forms) and have a first site set
> up,
> > you'll never ever look back.
> >
>
> Again, I am not interested in the templating but rather I would like
> to know what other features Django offers the web developer. I want to
> maintain control of the output, as my intention is to learn Python in
> a general sense. However, I do not want to reinvent security-related
> wheels such as sanitizing user input before sending to database, and
> such. Does Django offer this?


Yup. The ORM goes out of its way to make safe strings. You can circumvent it
but that's naturally on your head. The Form classes also go a long way to do
the same. Forms go some distance further to make validation really simple
too.

And you say you're not interested in Templating, but you will be once you've
used it a few times.


> > The Python is the easy bit. It mostly "just makes sense" until you see
> the
> > crazy-short ways of doing really quite complicated, cross entity data
> > filtering in a single line. And by that time you're hooked anyway ;)
> >
>
>
> Can you save me some googling and provide a link? While the Django
> community is growing, I am not having much luck finding real world
> code examples.


Okay for this bit, I have three models in play. User (built into Django),
UserProfile (an extension of User, locked in with a foreign key) and
Company, referred to by UserProfile. In real DB terms there are 4 tables
there.

Say I want to list users that are part of a given company. Easy:

    users = [u.user for u in UserProfile.objects.filter(company=company)]


How about I want to filter another Model that has an FK on User, again,
given a company? Still super easy:

    data = AnotherModel.objects.filter(user__in = [u.user for u in
UserProfile.objects.filter(company=company)])


How about dynamic sorting? Here's how I exposed table-header based sorting
so you can sort by a named column and specify an order, with defaults if
nothing is specified:

    data = data.order_by('%s%s' % (request.GET.get('order', '-'),
request.GET.get('orderby', 'when')))


These sorts of things can be nauseating to implment. They're usually easy
but time consuming. Now they're just easy.

To find out how it'll effect you though, you just need to get stuck in.

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to