I was presenting a Django demonstration to my brother and he asked me the following question(s): "Why Django static and media folders aren't pre-configured? It's purpose aren't to be a convention over configuration framework? Why I am supposed to configure these things every time I start a Django project?"

I couldn't answer to him. Does anyone can?

P.S: I don't mean to compare Django with other frameworks. I'm just trying to understand why these design decisions were made;

有帮助吗?

解决方案

Django is very definitely not a convention over configuration framework. Your brother is perhaps thinking of Rails, which does follow that principle - but Django follows the Python principle of "explicit is better than implicit".

其他提示

Because django shouldn't distribute media files anyway. When you read the documentation you can see that the static files should (and must) be distributed by your server engine and/or by some kind of CDN when you are in production. Django, is just here to process your pages but not your media. And when you are in development, indeed, you have to use django to distribute static files. But you can use a python script to generate it, and manage it. For me, one of the best is: Django mediagenerator. This will let your files like they are in dev mode, but this will optimize it in production.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top