Skip to content

Commit

Permalink
Make urls.py a file that is always baked. (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
smk4664 authored Nov 21, 2024
1 parent f20c398 commit e9b4d0c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 0 additions & 1 deletion nautobot-app/hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"tests/test_form_{{ cookiecutter.model_class_name.lower() }}.py",
"tests/test_model_{{ cookiecutter.model_class_name.lower() }}.py",
"tests/test_views.py",
"urls.py",
"views.py",
]
for file in files_to_remove:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@
from django.views.generic import RedirectView
from nautobot.apps.urls import NautobotUIViewSetRouter

{% if cookiecutter.model_class_name != "None" %}
from {{ cookiecutter.app_name }} import views
{% else %}
# Uncomment the following line if you have views to import
# from {{ cookiecutter.app_name }} import views
{% endif %}

router = NautobotUIViewSetRouter()
{% if cookiecutter.model_class_name != "None" %}
router.register("{{ cookiecutter.model_class_name | lower }}", views.{{ cookiecutter.model_class_name }}UIViewSet)
{% else %}
# Here is an example of how to register a viewset, you will want to replace views.{{ cookiecutter.camel_name }}UIViewSet with your viewset
# router.register("{{ cookiecutter.app_name }}", views.{{ cookiecutter.camel_name }}UIViewSet)
{% endif %}

urlpatterns = [
path("docs/", RedirectView.as_view(url=static("{{ cookiecutter.app_name }}/docs/index.html")), name="docs"),
Expand Down

0 comments on commit e9b4d0c

Please sign in to comment.