224889_condition_critical1.jpgThere was quite a discussion about John Taber using Django for two weeks and then switching back to RoR.
Like him, I’m also relatively new to the Django framework but worked with Symfony for the last years instead of RoR – in this blog post I would like to say my opinion about a few of the mentioned points.

Documentation

The documentation is definitely one of the strongest points about the Symfony framework, even Yahoo! likes to point out the good documentation.

I found the Django documentation on the other hand a little unorganized, but it really helped me to take a look at the docs-folder in svn to get a better overview of the available documents/tutorials.

However, there are also many other resources you can use, here’s what I’ve mostly used so far:

Routes

I don’t know how RoR does routing but Symfony’s routing.yml and Django’s urlconf aren’t really that different at all.

Let’s imagine we’ve a small news website and want to display the details of our post under a url which looks like “/25-10-2007/how-to-do-something”.

Here’s how this url is described in Symfony:

news_show:
  url: /news/:date/:urltitle
  param: { module: news, action: show }
  requirements: { date: ^\d\d-\d\d-\d{4}$, urltitle: [-\w]+ }

Now, let’s take a look at how this would look like in Django:

url(r'^(?P<date>\d\d-\d\d-\d{4})/(?P<urltitle>[-\w]+)$', 'test.news.views.show', name="news_show")

Even shorter and not that different, right?

Static media

In Symfony you just have to drop your files in the “web” folder, in Django however it’s not as clear to new users.
Although the Django documentation shows you how to use the static.serve view to serve those files in the development environment, it also notes not to use it in production because it’s highly inefficient and insecure and instead just recommends using Apache or lighttpd.

To me, it’s still a little bit unclear what’s the best method to serve static files and i can just hope the devs could update the documentation and include some real-world examples and helpful tips (like this one from Jeremy Dunck).


100_4260.jpgWelcome to Djangoniac – a blog about my impressions, problems and simply all the other stuff about Django that comes to my mind. My name is Arthur Koziel and in the past few years i’ve mostly been focused on PHP and the Rapid Development Framework Symfony (I also run a blog called Symfoniac).

While currently still learning Django (Python) i really hope to go mostly PHP-free in the next years (can’t go completely free because of a few PHP projects that i still need to maintain and a PHP course in college) and do some very interesting projects with Django.




Follow

Get every new post delivered to your Inbox.