npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

generator-broagency

v0.0.1

Published

Generator for django projects and applications

Downloads

1

Readme

generator-bro

This generator help you create django projects, apps, models and views very faster. See usage section for more information. This project based on yeoman generator.

Install

npm install -g git://github.com/lutowolk/generator-bro 

Usage

Package contain next generators:

bro

This generator will create a django project.

Run

$ yo bro [<args>] [<options>]

Args

First arg - project name;

Second arg - django database backend. One of this: postgresql_psycopg2, mysql, sqlite3, oracle;

Third arg - database user.

Four arg - database user password.

All this args is not required.

Example

This command create project with name blog.

$ yo bro blog

Project will be have next file structure:

blog
├─ client
└─ server
   ├─ apps
   |  └─ __init__.py
   ├─ libs
   ├─ contrib
   ├─ config
   |  ├─ settings
   |  |  ├─ installed_apps.py
   |  |  ├─ local.py
   |  |  ├─ settings.py
   |  |  ├─ __local.py
   |  |  └─ __init__.py
   |  ├─ urls.py
   |  ├─ wsgi.py
   |  └─ __init__.py
   ├─ templates
   |  └─ base.html
   ├─ manage.py
   ├─ requirments.txt
   └─ __init__.py

bro:sub

This generator will create a django app in server.apps directory. Also new app will be include to settings and root urlconf.

Note: before running this command move to project directory.

Run

$ yo bro:sub <app_name> [<options>]

Example

This command create app with name news in .

$ yo bro:sub news

App will be have next file structure:

news
├─ models
|  ├─ mixins
|  |  └─ __init__.py
|  └─ __init__.py
├─ views
|  ├─ mixins
|  |  └─ __init__.py
|  └─ __init__.py
├─ factories
|  └─ __init__.py
├─ admin
|  ├─ mixins
|  |  └─ __init__.py
|  └─ __init__.py
├─ tests
|  ├─ models
|  |  └─ __init__.py
|  ├─ views
|  |  └─ __init__.py
|  └─ __init__.py
└─ __init__.py

bro:model

This generator will create a django model in server.apps.your_app.models directory. For new model will be created admin class. If model containg field with name slug for this field will be created prepopulated field.

Admin and model classes will be imported in __init__.py files.

Note: before running this command move to project directory.

Run

$ yo bro:model <app_name:model_name> [<field_name:field_type[:arg1,arg2=val]> ...] [<options>]

Options

  • -s, --def-save Create model method save for next overriding.
  • -p, --prepopulated Set prepopulated field name for slug field. Use this option if field slug exist and prepopulated field name differs from name or title.

Example

This command create model Blog in app blogs in .

$ yo bro:model blogs:Blog title:char slug:slug content:text publish:bool:default=True

File content for new file blogs.models.blog.py:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
from django.utils.translation import ugettext as _


class Blog(models.Model):
    title = models.CharField(verbose_name=_("title"), max_length=255)
    slug = models.SlugField(verbose_name=_("slug"))
    content = models.TextField(verbose_name=_("content"))
    publish = models.BooleanField(verbose_name=_("publish"), default=True)

    class Meta:
        verbose_name = _("Blog")
        verbose_name_plural = _("Blogs")

    def __unicode__(self):
        return self.title

    # your custom methods

Structure blogs app after creating model:

blogs
├─ models
|  ├─ mixins
|  |  └─ __init__.py
|  ├─ blog.py
|  └─ __init__.py
├─ admin
|  ├─ mixins
|  |  └─ __init__.py
|  ├─ blog.py
|  └─ __init__.py
└─ __init__.py

bro:view

With help this generator you may create generic view for your model. Just enter your model name and generator create views for this model. Generator support next generic view: ListView, DetailView, CreateView, UpdateView and DeleteView. You can tell the generator what kind of views you want to create with options.

Note: before running this command move to project directory.

Run

$ yo bro:model <app_name:model_name> [<options>]

Options

  • --list for create ListView
  • --detail for create DetailView
  • --create for create CreateView
  • --update for create UpdateView
  • --del for create DeleteView
  • --paginate set property paginate_by for class ListView usage this options with option list, default value 5

Example

This command create all views for model Blog (see this model in above).

$ yo bro:view blogs:Blog --list --detail --create --update --del

After this command will be executed, will be created five classes in file server/apps/blogs/views/blog.py:

  • BlogListView
  • BlogDetailView
  • BlogCreateView
  • BlogUpdateView
  • BlogDeleteView

Also will be created new form class BlogForm in file server/apps/blogs/forms/blog.py and include in BlogCreateView and BlogUpdateView. This views will be included in urls conf (server/apps/blogs/urls.py). With view BlogDetailView will be created method get_absolute_url in model Blog. For this views also will be created base templates witch contain data about models.

New files:

  • # server/apps/blogs/views/blog.py
  • # server/apps/blogs/forms/blog.py
  • # server/templates/blogs/blog_detail.html
  • # server/templates/blogs/blog_form.html
  • # server/templates/blogs/blog_list.html

Changed files:

  • # server/apps/blogs/urls.py
  • # server/apps/blogs/models/blog.py
  • # server/apps/blogs/forms/__init__.py

Sponsors

This project is developed with the financial support of bro.agency.

Contributing

If you find errors or you know how improve this project please create issue in this page.