Initial Setup¶
Use a Development Environment, Not Production For App Development
You should not use your production environment for app development. For information on getting started with a development environment, check out Nautobot development guide.
Note
The Nautobot organization provides a Python CookieCutter to help get started with your applications. Get started at https://github.com/nautobot/cookiecutter-nautobot-app.
App Structure¶
Although the specific structure of an app is largely left to the discretion of its authors, a Nautobot app that makes use of all available app features described in this document could potentially look something like this:
app_name/
- app_name/
- __init__.py # required
- admin.py # Django Admin Interface
- api/
- serializers.py # REST API Model serializers
- urls.py # REST API URL patterns
- views.py # REST API view sets
- banner.py # Banners
- custom_validators.py # Custom Validators
- datasources.py # Loading Data from a Git Repository
- filter_extensions.py # Extending Filters
- filters.py # Filtersets for UI, REST API, and GraphQL Model Filtering
- forms.py # UI Forms and Filter Forms
- graphql/
- types.py # GraphQL Type Objects
- homepage.py # Home Page Content
- jinja_filters.py # Jinja Filters
- jobs.py # Job classes
- middleware.py # Request/response middleware
- migrations/
- 0001_initial.py # Database Models
- models.py # Database Models
- navigation.py # Navigation Menu Items
- secrets.py # Secret Providers
- signals.py # Signal Handler Functions
- table_extensions.py # Extending Tables
- template_content.py # Extending Core Templates
- templates/
- app_name/
- *.html # UI content templates
- urls.py # UI URL Patterns
- views.py # UI Views and any view override definitions
- pyproject.toml # *** REQUIRED *** - Project package definition
- README.md
The top level is the project root. Immediately within the root should exist several items:
pyproject.toml
- This is the new unified Python project settings file that replacessetup.py
,requirements.txt
, and various other setup files (likesetup.cfg
,MANIFEST.in
, among others).README.md
- A brief introduction to your app, how to install and configure it, where to find help, and any other pertinent information. It is recommended to write README files using a markup language such as Markdown.- The app source directory, with the same name as your app.
The app source directory contains all of the actual Python code and other resources used by your app. Its structure is left to the author's discretion, however it is recommended to follow best practices as outlined in the Django documentation. At a minimum, this directory must contain an __init__.py
file containing an instance of Nautobot's NautobotAppConfig
class.