Django for a Rails Developer
uswaretech.com
uswaretech.com
* urls point to views
* views do stuff. Perhaps hard, manly stuff. Perhaps involving models. Django views have hard, beefy beceps. They're awfully controlling.
* the view passes a dict of results to the template, which is sent as a response to the browser.
Once you get that, it's not so hard.
At the risk of being negative, I think the real issue is that the extensive documentation is geared more towards designers than hackers.
There's nothing wrong with that. Even the djangoproject.com website does it: http://code.djangoproject.com/browser/djangoproject.com/djan...
"Why serving static files in development has to be a additional setup, as no developer wants to setup a server for serving static files, I am aware of ‘django.static.serve’ but still that is an additional setup, why not create a sample media directory and a url for the same in urls.py ?"
But if you want it right now: create a custom command to do it your way and wrap it in an app that you add to the path. When you start a new project, the first thing you do is add the application to your installed apps and you can use it over and over again.
I've never had project that didn't need:
- a project-wide templates/ directory - media/[css|img|js] directories - some kind of database setup by default - contrib.admin (well, I created a form mailer once that had no admin)
Django seems to take a "we don't want to force you to use any particular setup" stance, but the result seems to be to force you to make a bunch of relatively meaningless decisions before you can start writing code. (they could have other reasons, I haven't looked into it lately)
These days I have a script that does all this, and I know others have written similar scripts as well. It just strikes me as being a gaping hole on the Django development model... IMO anyway.
But if you think it's a problem, why not publish whatever you use and encourage others to use it as well?
(also, FWIW I don't have such a script -- a new site at work always simply inherits default settings from other stuff, and those defaults are set up to match how our production servers work)
I don't doubt it. Much like how there is the occasional "this is how I handle managing multiple settings for different systems" blog post, people have come up with their own systems because Django provides none.
> But if you think it's a problem, why not publish whatever you use and encourage others to use it as well?
http://github.com/tvon/django-gig
Written for personal use, so...
There is also "create project" or "project template", I forget the exact name, but it's on bitbucket or github... and "paster" from zopeskel seems to have potential to do something like this but it may be too zope specific, I don't know.
There are ways to do it, but IMO it's something the framework should be handling. As it stands, "basic setup and configuration" is a much higher hurdle in Django than it is in Rails.
> (also, FWIW I don't have such a script -- a new site at work always simply inherits default settings from other stuff, and those defaults are set up to match how our production servers work)
Well, you don't have a script that builds things out in a certain way, but you have a system in place that handles project defaults.
(Speaking of /bin directories, it's always bugged me that Rails renamed this directory to /scripts ... if it's executable, it goes in /bin, it makes no sense to split executables based on arbitrary implementation details)
For stuff at work apps all go into one of a couple particular namespaces, so packaging concerns don't come up there; for my personal stuff the package name is almost never the same as the app anyway (e.g., django-registration provides an app in a module named 'registration').
Also, I'd really really like the concept of the project to die soon.
It's a different philosophy, but it's hard getting use to having to explicitly spell out everything when I just want to get going with defaults that make sense.
put all of your environment-specific variables in there, and put 'from local_settings.py import *' at the end of your settings.py
It is, see PEP 8: http://www.python.org/dev/peps/pep-0008/