Ask HN: Transitioning From PHP to Django
I feel like my primary concern would be getting the new Django app to play nice with the existing mysql database.
Has anyone had any experience doing this? Thanks.
I feel like my primary concern would be getting the new Django app to play nice with the existing mysql database.
Has anyone had any experience doing this? Thanks.
e.g, how is:
Entry.objects.filter(
headline__startswith='What').exclude(
pub_date__gte=datetime.now()).filter(
pub_date__gte=datetime(2005, 1, 1))
(from http://www.djangoproject.com/documentation/db-api/)easier than:
SELECT * from Entry where headline like "What%" and pub_date... wha? see? wtf is that chaining filter actually doing?
my 2 cents: write your own DB access layer, fight the obscure black magic.(nothing but quibbles with the templating engine, though)
for example, i can say:
grants = Grants.objects.filter(is_approved=True)
to get all of the Grants to an Organization, and then if not request.user.is_superuser:
grants = grant.filter(sponsoring_trustee=request.user)
to filter out grants that only pertain to a certain user."grants" isnt evaluated (queried) until its iterated over or otherwise called (print, for example), so i can keep building what i want as i go without having several sql calls or managing building a query via string concatenation. personally, i've always found django's orm to feel natural.
As long as your database design is somewhat decent you'll likely be ok. if not... well you might want to build a new model and migrate your data :)
But to answer your question, there probably wouldn't be any need to rewrite my application. PHP is very adaptable and scalable and will probably continue to suit my needs.