#!/bin/python #coding: utf-8 # +------------------------------------------------------------------- # | version:1.0 # +------------------------------------------------------------------- # | django-vue-lyadmin # +------------------------------------------------------------------- # | Author: lybbn # +------------------------------------------------------------------- # | QQ: 1042594286 # +------------------------------------------------------------------- # ------------------------------ # 代码生成--urls # ------------------------------ from django.template import Template,Context def lyGenerateUrls(object): urls_code = """# -*- coding: utf-8 -*- #路由文件 from django.urls import path, re_path from rest_framework import routers from apps.lyautocode.views.views_{{object.class_name}} import {{object.class_name}}ViewSet system_url = routers.SimpleRouter() system_url.register(r'{{ object.class_name }}', {{object.class_name}}ViewSet) urlpatterns = [] urlpatterns += system_url.urls """ context = Context({'object': object}) return Template(urls_code).render(context)