• modify django app models.py adn settings.py


    from django.db import models
    from django.contrib import admin
    # from personal import models
    
    
    class UserInfo(models.Model):
        name = models.CharField(max_length=30)
        email = models.EmailField()
        memo = models.ImageField()# .CharField(max_length=300) # upload_to='/assets'
        date_time = models.DateTimeField(auto_now=True, editable=False)
    
        class Meta:
            verbose_name_plural = '用户信息'    # modify
    
    
    class UserInfoAdmin(admin.ModelAdmin):
        list_display = ('name', 'email', 'memo', 'date_time')
        list_editable = ('email', 'memo')
        search_fields = ('name', 'memo', 'email')
        list_filter = ('date_time', )
    
    admin.site.register(UserInfo)

     django project settings.py

    DATABASES = {
        'default': {
            # sqlite3
            # 'ENGINE': 'django.db.backends.sqlite3',
            # 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    
            # mysql
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'work',
            'USER': 'root',
            'PASSWORD': '123',
            'HOST': 'localhost',
            'PORT': '3306',
        }
    }
  • 相关阅读:
    模拟tap事件和longTap事件
    jquery工具方法总结
    outline:0与outline:none区别
    babel吐槽
    兼容ie8 rgba()写法
    git删除文件夹
    css简写总结
    回调函数实例—(二)
    回调函数的那些事儿(转载)
    回调函数好文章汇总
  • 原文地址:https://www.cnblogs.com/vickey-wu/p/8340556.html
Copyright © 2020-2023  润新知