Is there any adequate scaffolding for Django? (A la Ruby on Rails)

前端 未结 6 1519
遇见更好的自我
遇见更好的自我 2021-01-31 17:34

Is there any adequate scaffolding for Django?

It may be in the newly released 1.3 version, but I haven\'t found it yet.

6条回答
  •  北荒
    北荒 (楼主)
    2021-01-31 17:57

    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.

提交回复
热议问题