Giter Site home page Giter Site logo

djgo's Introduction

djgo

Description

This package provides some shortcuts for your django app.

Installation

pip install djgo

Usage

djgo has shortcuts for different parts of the app. To use it, simply import it with import djgo.

manage.py

Method start_django() (or manage()) is a shortcut for launching Django.

wsgi.py

Method set_wsgi() is a shortcut that sets Django settings env variable and returns default wsgi application.

urls.py

Method load_app() is a shortcut that loads and returns an app module or its part.

app/contrib.py

Method app_config() is a shortcut that sets Django app config. Example:

from djpp import app_config
default_app_config = app_config(verbose_name='My Cool App')

app/models.py

Decorator @meta is a shortcut that sets meta and __str__() for your model.
WARNING: All meta defined this way won't register in migrations.
Example:

@meta(single='My Client', plural='My Clients', display='name')
class Client(models.Model):
    name = models.CharField()

is equal to

class Client(models.Model):
    name = models.CharField()
    class Meta:
        verbose_name = 'My Client'
        verbose_name_plural = 'My Clients'
    def \_\_str\_\_():
        return self.name

except the meta (name and verbose_name) won't register in migrations.

You can also pass functions to display:

@meta('My Client', display=lambda self: 'Cool ' + str(self.name))
class Client(models.Model):
    name = models.CharField()

is equal to

class Client(models.Model):
    name = models.CharField()
    class Meta:
        name = 'My Client'
        verbose_name = 'My Client'
    def \_\_str\_\_():
        return 'Cool ' + str(self.name)

except the meta (name and verbose_name) won't register in migrations.

djgo.admin

djgo has a small set of methods for admin site and admin.py file:

  • admin.urls is a shortcut for path('url', admin.site.urls), except adds '/' in the end of your url string if it doesn't have one.
  • admin.meta is a shortcut for setting admin.site.site_header and admin.site.site_title.
  • admin.clear_models is a shortcut for clearing models from admin site registry.
  • admin.quick_inline is a decorator for setting some tabular inline params.

Other features

You can also access settings through djgo with djgo.settings!

Lastly, djgo provides a small log() method for printing some info.

djgo's People

Contributors

ceterai avatar

Watchers

 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.