Skip to content

TAMU-CPT/cc-automated-drf-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cc-automated-drf-template

cc_automated_drf_template uses Cookiecutter and a custom script to automatically populate a Django REST project given a models.py. Just provide your models.py and cc_automated_drf_template will write your views, serializers, urls, and admin files for you.

Features

  • Django REST Framework integration
  • Support for multiple apps
  • JWT authentication
  • Fully populated serializers.py, views.py, urls.py, admin.py

Installation

Install Cookiecutter:

$ pip install cookiecutter

Give names for your directory, project, and app when prompted by Cookiecutter:

$ cookiecutter https://github.com/TAMU-CPT/cc-automated-drf-template.git
dir_name [test-project]:
project_name [project]:
app_name [base_app]:

Modify your models.py file in your app. Then navigate to where manage.py and script.py are located and run:

$ python script.py

The script will install all requirements and automatically apply migrations.

That's it! You now have automatically-templated views, serializers, urls, and admin files based on your models. To check it all out, run the server. Don't forget to activate your virtualenv! You may also want to createsuperuser so that you can log in to the admin interface.

$ . venv/bin/activate
$ python manage.py createsuperuser
$ python manage.py runserver

Note on virtual environments:

If you have already set up/activated a virtual environment, make sure to use the --disable_venv flag. Otherwise, a virtualenv will be created for you.

Multiple app support

Some Django projects have multiple apps in addition to the base application. If you want to similarly generate files for these apps, you may run the script again using the --app_name flag, like this:

(venv) $ python script.py --app_name another_app --disable_venv

Since I am already in a venv, I also used --disabe-venv.

Note on file changes:

If you have modified views, serializers, urls, or admin files before running the script or are unsure of the changes made after running it, make sure to git add -p to add or ignore changes that will be staged in the next commit.

What's next?

If you are looking to add a front end, check out CICADA, which will automatically template an AngularJS frontend that will plug in to the backend you just created.

License

This software is licensed under BSD-3-Clause

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages