zoukankan      html  css  js  c++  java
  • django中models

    字段类型:

        models.CharField  
        models.ForeignKey
        models.DateTimeField
        models.BinaryField
        models.BooleanField
        models.IPAddressField
        models.IntegerField
        models.FileField
        models.ImageField

    Meta:

    class Meta:
            verbose_name = '用户留言信息'
            verbose_name_plural=verbose_name
            db_table = 'usermessage'
            ordering = 'object_id'

    视图中添加数据到数据库:

    1、create 一步到位

    UserMessage.objects.create(name='yun',email='2@2.com',address='shanghai',message='nihao')

    2、save 先创建模型实例,再设置字段值,最后保存

    user_message = UserMessage()
    user_message.name = '天天'
    user_message.email = '3@3.com'
    user_message.address = '洛阳'
    user_message.message = '不错'
    user_message.save()

    删除:

    message.delete()
    渐变 --> 突变
  • 相关阅读:
    KMP
    Trie 树
    Miller-Rabin质数测试
    快速幂
    Matlab 对图片的二值化处理
    huffman tree
    hdu5512-Pagodas
    迷宫
    poj2488-A Knight's Journey【DFS】
    linux操作
  • 原文地址:https://www.cnblogs.com/lybpy/p/8228102.html
Copyright © 2011-2022 走看看