Is there any adequate scaffolding for Django? (à la Ruby on Rails)
I've looked and not yet found something for Django quite like the Rails Generate command. Django has a bit of a different philosophy. It gives you tools to make doing things easily but doesn't actually do it for you (except the admin interface). In the grand scheme of things, I think this is OK. When I use rails' scaffolding I'm not able to often keep much of the auto-generated stuff. When I do, the django admin interface would probably also have worked and given me more functionality.
Instead, what I suggest is reading through the Django tutorial step 4, which introduces generic views, and then chapter 7 of the Django book which introduces forms. You have to be patient on chapter 7 because the authors think you want to know the minute details of the hard-way before they teach you the easy way. (try searching the page for the phrase django.forms)
In the end the amount of work you have to do between rails and django is equivalent, and maybe slightly less with Django. However you don't have one command to automatically give you boilerplate code to use as a foundation.
So Django 1.3 still lacks 'scaffold' functionality. Not good. What is best in scaffold, is that it allows developer to immediately start with the project, without recalling all 'models', 'urls' and 'views' syntaxes.
Look at this example, let's start new project and app:
$django-admin startproject mysite
$python manage.py startapp blog
and now we need to manually 'START' everything, from almost empty files. BUT it would be very convenient to do it in this way (like in rails)
$python manage.py scaffold app:blog model:Post title:string content:text
This should give us: models.py
class Post(models.Model):
title = models.CharField
content = models.TextField
views.py
def index(request):
posts = Post.objects.all().order_by('-id')
return render_to_response('blog/index.html', {'posts': posts})
and update urls.py somehow, ... or not, this is more complicated but less needed.
This should not be difficult to implement in future Django releases. I would do this if I had enough knowledge and experience in Django. Unfortunately I'm not doing many Django projects and that's why I need this functionality.
This one is closer to rails-like scaffolding: https://github.com/modocache/django-generate-scaffold