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', } }