zoukankan      html  css  js  c++  java
  • stark组件开发之自动生成URL

    app01model.py

    from django.db import models
    
    # Create your models here.
    
    
    class Depart(models.Model):
        id = models.AutoField(primary_key=True)
        title = models.CharField(verbose_name="部门名称", max_length=32)
    
    
    class UserInfo(models.Model):
        id = models.AutoField(primary_key=True)
        name = models.CharField(verbose_name="用户名", max_length=32)
        pwd = models.CharField(verbose_name="密码", max_length=16)
        age = models.IntegerField(verbose_name="年龄", max_length=3)
        depart = models.ForeignKey(verbose_name="部门", to="Depart", to_field="id", on_delete=models.CASCADE)
    View Code

    app02model.py

    from django.db import models
    
    # Create your models here.
    
    
    class Host(models.Model):
        '''主机表'''
        id = models.AutoField(primary_key=True)
        host = models.CharField(verbose_name="主机名", max_length=32)
        ip = models.GenericIPAddressField(verbose_name="IP", protocol="both")  # 支持ipv4 和 ipv6
    View Code

    如何完成这三张表的增删改查:

    为app中每个 model类, 自动创建 URL 以及函数:

    直接放几张图:

    自动生成url的类:

    app中:

     

    根路由:

    然后直接页面看。是不是生成了,这么多的 url:

    不要在意错误!!看是不是有了这个多的 url 。  事实整明!此法可行!

  • 相关阅读:
    ORACLE MOS 翻译
    Oracle内部latch获取函数简介
    oracle cost
    oracle function dtrace
    Oracle hidden costs revealed, Part2 – Using DTrace to find why writes in SYSTEM tablespace are slower than in others
    DTrace Oracle Database
    Oracle8i Internal Services
    oceanbase 分布式数据库
    中国国家安全漏洞库
    interesting-exploit
  • 原文地址:https://www.cnblogs.com/chengege/p/10732884.html
Copyright © 2011-2022 走看看