{ "info": { "author": "Leo Neto", "author_email": "leo@ekletik.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django :: 2.2", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3 :: Only", "Topic :: Software Development :: Libraries :: Application Frameworks", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# django-clite\n\nA CLI tool that handles creating and managing Django projects\n\n![PyPI - License](https://img.shields.io/pypi/l/django-clite?style=flat-square)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/django-clite?style=flat-square)\n![PyPI](https://img.shields.io/pypi/v/django-clite?style=flat-square)\n![Bitbucket Pipelines](https://img.shields.io/bitbucket/pipelines/oleoneto/django-clite/development?style=flat-square)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/django-clite?style=flat-square)\n\n- [django-clite](#django-clite)\n - [Requirements](#requirements)\n - [Installation](#installation)\n - [Commands](#commands)\n - [Create](#create)\n - [Creating new projects](#creating-new-projects)\n - [Project structure](#project-structure)\n - [Generator](#generator)\n - [Generating Models](#generating-models)\n - [Generating Serializers and Viewsets](#generating-serializers-and-viewsets)\n - [Generating Admin Models](#generating-admin-models)\n - [Generating Views](#generating-views)\n - [Generating Templates](#generating-templates)\n - [Generating Complete Resources](#generating-complete-resources)\n - [Destroyer](#destroyer)\n - [Run](#run)\n - [Running The Django Server](#running-the-django-server)\n - [To Do](#to-do)\n - [Pull requests](#pull-requests)\n - [LICENSE](#license)\n\n## Requirements\nCheck out [requirements.txt](requirements.txt) for all requirements.\n\n## Installation\nInstall via [pip](https://pypi.org/project/django-clite/):\n```bash\npip install django-clite\n```\n\nInstall from source:\n```\ngit clone https://bitbucket.org/oleoneto/django-clite.git\ncd django-clite\npip install .\n```\n\nAfter installation, the CLI will expose the binary with two names, any of which can be used in place of the another:\n```\nD\ndjango-clite\n```\n\n\n----\n\n## Commands\n```\ndestroy Deletes models, serializers, and other resources\ngenerate Adds models, routes, and other resources\ncreate Creates projects and apps\nrun Run maintenance, development, and deployment scripts.\n```\n\n### Create\nCreate project and applications.\n```\nCommands:\n app Creates new django apps.\n project Creates a new django project.\n```\nThe `create` command (abbreviated `c`) can be used to start new projects as well as new applications. The command tries to simplify how a project is created as well as the applications contained in it. Here's an example of such simplification:\n\nSuppose you want to start a new project and want to create two apps within it:\n```\ndjango-admin startproject mywebsite\ncd mywebsite/mywebsite/\ndjango-admin startapp blog\ndjango-admin startapp radio\n```\n\nThe equivalent command in the `django-clite` is:\n```bash\nD create project mywebsite blog radio\n```\n\nSpecifying `apps` when creating a project is optional, but you're likely to need to create one inside of your project directory, so the CLI can handle the creation of all of your apps if you pass them as arguments after your project name.\n\n#### Creating new projects\nTo create a new project, simply run `D create project project_name`. This command supports the following flags:\n\n**--flags:**\n\n```\n--docker Add support for Docker\n--dokku Add support for Dokku\n--custom-auth Add support for custom AUTH_USER_MODEL\n```\n\nThe `--docker` flag will create a `Dockerfile` as well as a `docker-compose.yml` file within your project. These are pre-configured to support the following services: web (the Django application itself), a database (`postgres`), proxy server (`nginx`), and a caching server (`redis`).\n\nThe `--dokku` flag will add dokku-specific configuration to your project within the `dokku` directory. The default configuration will allow you to push to your dokku-enabled remote server and deploy your Django project in an instant.\n\nThe `--custom-auth` flag is used to provide a simple override of the `AUTH_USER_MODEL`. This creates a `User` model under `authentication.models.user`. One can simply specify the override in `settings.py` by setting:\n\n```python\nAUTH_USER_MODEL = 'authentication.User'\n```\n\n#### Project structure\nThis CLI makes some assumptions about the structure of your Django project.\n1. It assumes that your apps are one level below the root of your project directory, one level below where `manage.py` is. For example:\n```\nmywebsite\n\u251c\u2500\u2500 mywebsite\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 __init__.py\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 blog\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 radio\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 settings.py\n\u2502\u00a0\u00a0 \u251c\u2500\u2500 urls.py\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 wsgi.py\n\u251c\u2500\u2500 manage.py\n\u2514\u2500\u2500 requirements.txt\n```\n\n2. It assumes that your app resources are grouped together by type in packages. For example:\n```\nradio\n\u251c\u2500\u2500 __init__.py\n\u251c\u2500\u2500 admin\n\u251c\u2500\u2500 apps.py\n\u251c\u2500\u2500 forms\n\u251c\u2500\u2500 middleware\n\u251c\u2500\u2500 migrations\n\u251c\u2500\u2500 models\n\u251c\u2500\u2500 serializers\n\u251c\u2500\u2500 templates\n\u251c\u2500\u2500 tests\n\u251c\u2500\u2500 urls.py\n\u251c\u2500\u2500 views\n\u2514\u2500\u2500 viewsets\n```\n\n3. Each class representing a `model`, `serializer`, `viewset`, or `form` is located in its own Python module. For example:\n```\nmodels/\n\u251c\u2500\u2500 album.py\n\u251c\u2500\u2500 artist.py\n\u2514\u2500\u2500 track.py\n```\n\nThis is done in order to aid the CLI with the creation and deletion of files\nin the project as we'll see under the [`generate`](#generator) and [`destroy`](#destroyer) commands.\n\n\n### Generator\nAdd application resources.\n```\nCommands:\n admin Generates an admin model within the admin package.\n form Generates a model form within the forms package.\n model Generates a model under the models directory.\n resource Generates an app resource.\n serializer Generates a serializer for a given model.\n template Generates an html template.\n test Generates a new TestCase.\n view Generates a view function or class.\n viewset Generates a viewset for a serializable model.\n\nOptions:\n --dry, --dry-run Display output without creating files.\n```\n\nThe generator is accessible through the `generate` command (abbreviated `g`).\n\n\n#### Generating Models\nIn order to generate a model, specify the type identifier and then the name of the attribute field. Type identifiers are abbreviated to a more generic name that omits the word `Field`. The input here is case-insensitive, but the fields will be properly CamelCased in the corresponding Python file as in the example below:\n\n```bash\nD generate model album text:title image:artwork bool:is_compilation\n```\n\nThis would add the following model `album.py` under the `models` directory:\n```python\nimport uuid\nfrom django.db import models\n\n\nclass Album(models.Model):\n title = models.TextField(blank=True)\n artwork = models.ImageField(blank=True, upload_to='uploads')\n compilation = models.BooleanField(default=False)\n\n # Default fields. Used for record-keeping.\n uuid = models.UUIDField(default=uuid.uuid4, editable=False)\n created_at = models.DateTimeField(auto_now_add=True, editable=False)\n updated_at = models.DateTimeField(auto_now=True, editable=False)\n\n class Meta:\n db_table = 'radio_albums'\n ordering = ['-created_at']\n\n def save(self, *args, **kwargs):\n super().save(*args, **kwargs)\n\n def __str__(self):\n return f'{self.uuid}\n```\nAs in the example above, the database table name is derived from both the app name (`radio`) and the model name (`album`).\n\nThis command supports the following flags:\n```\n--abstract Creates an abstract model type.\n--register-admin Register model to admin site.\n--register-inline Register model to admin site as inline.\n--test-case Creates a TestCase for model.\n--full Adds all related resources and TestCase\n--inherits Add model inheritance.\n-v, --view Make model an SQL view.\n```\n\nNote the presence of the `--inherits` flag. You can specify a base model and the generated model will extend it. For example:\n```bash\nD generate model track -i audio\n```\n\nWill generate the following model:\n\n```python\nimport uuid\nfrom django.db import models\nfrom .audio import Audio\n\n\nclass Track(Audio):\n # model fields here...\n```\n\n**Defaults**\n\nAs one can see, `class Meta` and `_str_` are added to a model by default along with `uuid`, `created_at` and `updated_at` fields.\nThe `db_table` name is inferred from the name of the app and the current model while the ordering attribute is defined based on the default `created_at` field.\n\n\n**Relationships**\n\nIf a relationship identifier is passed, the attribute name will be used as the name of the model it relates to.\nSpecifying a relationship also checks the current app scope for the specified related model. If such model does not exist in scope, the CLI will prompt you to create the missing model. How to invoke the command:\n\n```bash\nD generate model track char:title belongsto:album\n```\n\nWhat the output would look like:\n```python\nimport uuid\nfrom django.db import models\nfrom .album import Album\n\nclass Track(models.Model):\n title = models.CharField(max_length=100)\n album = models.ForeignKey(Album, related_name='tracks', on_delete=models.PROTECT)\n\n # Default fields. Used for record-keeping.\n uuid = models.UUIDField(default=uuid.uuid4, editable=False)\n created_at = models.DateTimeField(auto_now_add=True, editable=False)\n updated_at = models.DateTimeField(auto_now=True, editable=False)\n\n class Meta:\n db_table = 'radio_tracks'\n ordering = ['-created_at']\n\n def save(self, *args, **kwargs):\n super().save(*args, **kwargs)\n\n def __str__(self):\n return f'{self.uuid}'\n```\n\nUse either of the following identifiers to specify relationships:\n- **ForeignKey**\n - belongsto\n - fk\n - foreignkey\n- **ManyToManyField**\n - hasmany\n - many\n - manytomany\n- **OneToOneField**\n - hasone\n - one\n - onetoone\n\n\n#### Generating Serializers and Viewsets\nIf you are working on an API and use the `Django REST Framework` to support your backend, you can also use the `django-clite` to create `serializers` and `viewsets`.\n\nThe commands are much like the ones used to generate a model except you don't specify any model attributes, just the model name:\n```bash\nD generate serializer album\n```\n\nWhich outputs:\n```python\nfrom rest_framework import serializers\nfrom .models import Album\n\n\nclass AlbumSerializer(serializers.ModelSerializer):\n\n class Meta:\n model = Album\n fields = \"__all__\"\n```\n\nSimilarly, a `viewset` can be generated like so:\n\n```bash\nD generate viewset album\n```\n\nWhich in turn would generate the following `viewset`:\n```python\nfrom rest_framework import viewsets\nfrom rest_framework import permissions\nfrom .router import router\nfrom ..models import Album\nfrom ..serializers import AlbumSerializer\n\n\nclass AlbumViewSet(viewsets.ModelViewSet):\n queryset = Album.objects.all()\n serializer_class = AlbumSerializer\n permission_classes = [permissions.IsAuthenticatedOrReadOnly]\n \nrouter.register('albums', AlbumViewSet)\n```\n\n#### Generating Admin Models\n```bash\nD generate admin album\n```\n\nThis will generate an admin model (inlines supported through `--inline`). The admin model class will be saved under `admin/album.py`, or if an inline model, under `admin/inlines/album.py`:\n\n```python\nfrom django.contrib import admin\nfrom ..models import Album\n\n@admin.register(Album)\nclass AlbumAdmin(admin.ModelAdmin):\n pass\n```\n\nAn inline model would look like this:\n```python\nfrom django.contrib import admin\nfrom ...models import Album\n\nclass AlbumInline(admin.StackedInline):\n model = Album\n extra = 1\n```\n\n#### Generating Views\n```bash\nD generate view album --list\n```\n\nSpecifying a flag of `--list` will generate a ListView as the one below. The `detail` flag will generate a DetailView. These are both class-based views. If a function-based view is preferred instead, one can simply run `D generate view blog`, to generate a view with the name `blog_view`.\n\n```python\nfrom django.utils import timezone\nfrom django.view.generic.list import ListView\nfrom ..models import Album\n\nclass AlbumListView(ListView):\n\n model = Album\n paginate_by = 20\n\n def get_context_data(self, **kwargs):\n context = super().get_context_data(**kwargs)\n context['now'] = timezone.now()\n return context\n```\n\nWhen generating list or detail views, the model name is inferred from the view name. This ensures consistency, as it also helps with other cli-related automation.\n\n#### Generating Templates\n```\nD generate template homepage\n```\n\nThis command will simply generate an HTML template with the specified name.\n\n```jinja2\n{% load static from staticfiles %}\n\n{% comment %}\n Template for homepage\n Describe the template here.\n{% endcomment %}\n\n{% block header %}{% endblock header %}\n\n{% block body %}{% endblock body %}\n\n{% block footer %}{% endblock footer %}\n\n{% block scripts %}{% endblock scripts %}\n```\n\n----\n\n#### Generating Complete Resources\nThe `resource` sub-command is ideal if you want to add a model along with admin, serializer, view, viewset, template, and tests. You can invoke the command the same way you would the model command:\n```bash\nD generate resource album text:title image:artwork bool:is_compilation fk:album\n```\nThis will generate a model with the specified attributes and all the related classes specified above. For consistency sake, the underlying implementation will prompt you for the same things the `model` sub-command would.\n\n\n### Destroyer\nRemove application resources.\n```\nCommands:\n admin Destroys an admin model or inline.\n form Destroys a form.\n model Destroys a model.\n resource Destroys a resource.\n serializer Destroys a serializer.\n template Destroys a template.\n test Destroys a TestCase.\n view Destroys a view.\n viewset Destroys a viewset.\n\nOptions:\n --dry, --dry-run Display output without deleting files\n```\n\nThis command can be used to undo all that the generator can create.\nSo, following our example `Album` model, one can remove it from the project by simply running:\n\n```bash\nD destroy model album --full\n```\n\nThe `--full` flag will ensure all related modules (forms, serializers... etc) are also removed along with the specified model.\n\n**Note**: Beware of application errors that may result from incorrectly destroying resources in use within your project. While this command will try to remove modules and packages related to the specified resource (including import statement from package-level init modules), it will not delete database migrations nor will it try to remove references to the resource from your codebase.\n\n----\n\n\n### Run\nRun maintenance, development, and deployment scripts.\n```\nCommands:\n server Runs the development server or another one of choice.\n```\n\n#### Running The Django Server\nUse this command to run the Django's default server. Run it like so:\n```\nD run server -p 3000\n```\n\n## To Do\n[Check open issues.](issues)\n\n## Pull requests\nFound a bug? Have an idea for new command? Contributions are very much welcome.\n\n## LICENSE\n**django-clite** is [BSD Licensed](LICENSE.txt).", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/oleoneto/django-clite", "keywords": "django automate cli command line tools rails ember python framework", "license": "BSD", "maintainer": "", "maintainer_email": "", "name": "django-clite", "package_url": "https://pypi.org/project/django-clite/", "platform": "any", "project_url": "https://pypi.org/project/django-clite/", "project_urls": { "Documentation": "https://bitbucket.org/oleoneto/django-clite/", "Homepage": "https://bitbucket.org/oleoneto/django-clite", "Source Code": "https://bitbucket.org/oleoneto/django-clite/" }, "release_url": "https://pypi.org/project/django-clite/0.1.0b0/", "requires_dist": null, "requires_python": "", "summary": "CLI for managing Django projects", "version": "0.1.0b0" }, "last_serial": 5762697, "releases": { "0.0.9b1": [ { "comment_text": "", "digests": { "md5": "2e7cac9b009bfa16c0d40eb35d0ad7b3", "sha256": "152c5ee72605bb5754722877d70d495bdacd4cef62615771e40c46ff1504d1d3" }, "downloads": -1, "filename": "django-clite-0.0.9b1.tar.gz", "has_sig": false, "md5_digest": "2e7cac9b009bfa16c0d40eb35d0ad7b3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33750, "upload_time": "2019-07-13T05:03:05", "url": "https://files.pythonhosted.org/packages/9a/4c/c77d37d4bc71c72aa42b063d727ebde4c9a2617373f569993c7a9bd8bcba/django-clite-0.0.9b1.tar.gz" } ], "0.0.9b2": [ { "comment_text": "", "digests": { "md5": "744e7fcea69d8d4f6578b9ef46a43cb5", "sha256": "bfe0a8599bedd0ab323465b9ca1f614a1f527eae022ad96088a59691aa9e291f" }, "downloads": -1, "filename": "django-clite-0.0.9b2.tar.gz", "has_sig": false, "md5_digest": "744e7fcea69d8d4f6578b9ef46a43cb5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34005, "upload_time": "2019-07-13T05:27:15", "url": "https://files.pythonhosted.org/packages/d0/ca/cecb2d05668e04dc58e3115eede94d6e9a0036f92075936cb06ead2ce9fa/django-clite-0.0.9b2.tar.gz" } ], "0.0.9b3": [ { "comment_text": "", "digests": { "md5": "d0cdd490716277cb888798aecf8df967", "sha256": "97f466710a9f9d521c468aa3e7915d1b66123e96cf119900cda60bf5d4e258a4" }, "downloads": -1, "filename": "django-clite-0.0.9b3.tar.gz", "has_sig": false, "md5_digest": "d0cdd490716277cb888798aecf8df967", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 34004, "upload_time": "2019-07-13T05:54:11", "url": "https://files.pythonhosted.org/packages/89/a5/5e01f5a5a2a79b4ca50f4fe1e87d7cc1acc4c802e42dcdc5171571245e91/django-clite-0.0.9b3.tar.gz" } ], "0.0.9b4": [ { "comment_text": "", "digests": { "md5": "b2138a513f0f7881c7fb2cb39e8c9499", "sha256": "82f61fef9ebc68f75ad71efce73867298d12345a29bc5b92b1af2ad5f4524d08" }, "downloads": -1, "filename": "django-clite-0.0.9b4.tar.gz", "has_sig": false, "md5_digest": "b2138a513f0f7881c7fb2cb39e8c9499", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 33719, "upload_time": "2019-07-13T06:14:45", "url": "https://files.pythonhosted.org/packages/c5/62/3f77ddb691a314106725f0b67bce8a914f7a66f39dbd41cd23520d7e478a/django-clite-0.0.9b4.tar.gz" } ], "0.0.9b6": [ { "comment_text": "", "digests": { "md5": "25775390c34fa066c4696f7ddd18d377", "sha256": "8f37bd583e4af126b9caa1d0c8248c93d2ea8502ed08c52b6f4fd9506c471d79" }, "downloads": -1, "filename": "django-clite-0.0.9b6.tar.gz", "has_sig": false, "md5_digest": "25775390c34fa066c4696f7ddd18d377", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 38607, "upload_time": "2019-07-22T16:54:21", "url": "https://files.pythonhosted.org/packages/1f/1a/d173e2bb131c6ca9edb65b181f65070c6e2b8cd73446d464ba5795b11f23/django-clite-0.0.9b6.tar.gz" } ], "0.0.9b7": [ { "comment_text": "", "digests": { "md5": "a44afaa0a58da53c9bbd4f38a5ec2309", "sha256": "ca8acfc683ff9822ba8ad7872c8113e654b022feba878c99a775d8f2caa7ed78" }, "downloads": -1, "filename": "django-clite-0.0.9b7.tar.gz", "has_sig": false, "md5_digest": "a44afaa0a58da53c9bbd4f38a5ec2309", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 39082, "upload_time": "2019-08-02T05:20:08", "url": "https://files.pythonhosted.org/packages/13/49/585ac8f282bea83d7065b090cd07e577f79ae7ad05d640269d43a2dc5020/django-clite-0.0.9b7.tar.gz" } ], "0.0.9b8": [ { "comment_text": "", "digests": { "md5": "fdea83bf7fb39eaf801bbf12e4aca0e0", "sha256": "7b540dbb87d4bacc7c79fec7bf36270a8ef8bde78adefafe41d5873f2673127b" }, "downloads": -1, "filename": "django-clite-0.0.9b8.tar.gz", "has_sig": false, "md5_digest": "fdea83bf7fb39eaf801bbf12e4aca0e0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 40719, "upload_time": "2019-08-16T05:34:02", "url": "https://files.pythonhosted.org/packages/4d/de/32328931e7c4356fbeb60afd3a99427b5e71ce4198383938e5f85c8fd5b3/django-clite-0.0.9b8.tar.gz" } ], "0.0.9b9": [ { "comment_text": "", "digests": { "md5": "d8d9336bca5a54629f0935663c993736", "sha256": "8b1eff0a0faf916fb8c725a22fd6515e432450397d74905d22149525bbfbd32d" }, "downloads": -1, "filename": "django-clite-0.0.9b9.tar.gz", "has_sig": false, "md5_digest": "d8d9336bca5a54629f0935663c993736", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 40700, "upload_time": "2019-08-30T23:24:50", "url": "https://files.pythonhosted.org/packages/d9/5c/77e10983ae2ced34dbde01a5c390ee97f3f80061d7da365424dde506fe3d/django-clite-0.0.9b9.tar.gz" } ], "0.1.0b0": [ { "comment_text": "", "digests": { "md5": "0510178697b9dead814376d0d769147c", "sha256": "8ad844164c39bb820131eed6b20e32a03072571bea51f2a296125c3810ee421d" }, "downloads": -1, "filename": "django-clite-0.1.0b0.tar.gz", "has_sig": false, "md5_digest": "0510178697b9dead814376d0d769147c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 40696, "upload_time": "2019-08-31T00:05:26", "url": "https://files.pythonhosted.org/packages/be/f2/bb82a1ace3e7f5bb0c267cefe881160013aa53c55c4d51acc874458beee7/django-clite-0.1.0b0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0510178697b9dead814376d0d769147c", "sha256": "8ad844164c39bb820131eed6b20e32a03072571bea51f2a296125c3810ee421d" }, "downloads": -1, "filename": "django-clite-0.1.0b0.tar.gz", "has_sig": false, "md5_digest": "0510178697b9dead814376d0d769147c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 40696, "upload_time": "2019-08-31T00:05:26", "url": "https://files.pythonhosted.org/packages/be/f2/bb82a1ace3e7f5bb0c267cefe881160013aa53c55c4d51acc874458beee7/django-clite-0.1.0b0.tar.gz" } ] }