GithubHelp home page GithubHelp logo

ruebenramirez / django-generate-scaffold Goto Github PK

View Code? Open in Web Editor NEW

This project forked from modocache/django-generate-scaffold

0.0 2.0 0.0 1.03 MB

Generate a Django model, views, URLconf, and templates using a single command.

django-generate-scaffold's Introduction

django-generate-scaffold build-status endorse

Generate a Django model, views, URLconf, and templates using a single command.

Quickstart

A screencast introducing django-generate-scaffold is available here.

Usage

Generating Models, Views, URL Patterns, and Templates

  • Install django-generate-scaffold:

      $ pip install django-generate-scaffold
    
  • Add generate_scaffold to your INSTALLED_APPS

  • Run the generatescaffold management command:

      $ python manage.py generatescaffold --help
      ... displays usage
    
  • Create a model using the syntax in the help message:

      $ python manage.py generatescaffold blogs Post title:string body:text is_public:bool blog:foreignkey=Blog
      ... Generates a Post model, with title (CharField), body (TextField),
      ...     is_public (BooleanField), and blog (ForeignKey) fields.
    

Generating Views, etc. Based on Existing Models

  • Alternatively, you can generate views, urlpatterns, and templates for an existing model:

      $ python manage.py generatescaffold blogs --model Post
      ... Generates views, etc. for Post
    
  • Note that if the model specified with the --model option has a DateField or a DateTimeField, date-based generic views will be generated based on that field. To specify a specific field to use, pass in the --timestamp-field option:

      $ python manage.py generatescaffold blogs --model Post --timestamp-field ctime
    

Limitations When Using Existing Models

For best results, existing models should implement a get_absolute_url method which conforms to the urlpatterns used by django-generate-scaffold:

    @models.permalink
    def get_absolute_url(self):
        return ('<app_name>_<model_name>_detail', (), {'pk': self.pk})

Not conforming to this model will lead to broken links and potentially other issues when rendering templates.

Development

django-generate-scaffold is currently in ALPHA.

Running Tests

In order to run the test suite, install your local version of django-generate-scaffold and start a Selenium server and issue the following commands:

    $ cd django-generate-scaffold
    $ python setup.py install --force
    $ cd test_project
    $ python test_app/tests/runtests.py

Consult .travis.yml for the exact steps necessary to run the test suite.

Autotesting via watchr

By installing the gems in the Gemfile, you can automatically run all non-Selenium based tests every time a file is modified:

    $ watchr autotest.rb

How to Contribute

  • Propose new features or report bugs by creating an issue on Github.
  • Add new features, tests, or fix stuff and issue a pull request.
  • Create a better, more eloquent screencast with less stammering.

Issues

If you experience any issues, please create an issue on Github.

django-generate-scaffold's People

Contributors

modocache avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.