parent
adce8d27f7
commit
b9942e15b6
7 changed files with 103 additions and 13 deletions
@ -0,0 +1,25 @@ |
||||
# Generated by Django 4.2.3 on 2023-07-27 01:17 |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
|
||||
dependencies = [ |
||||
('form_demo', '0002_alter_userstatus_id'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.CreateModel( |
||||
name='ImgFile', |
||||
fields=[ |
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
('name', models.CharField(default='', max_length=30, verbose_name='名称')), |
||||
('heading', models.FileField(upload_to='uploads/', verbose_name='文件')), |
||||
], |
||||
options={ |
||||
'verbose_name': '用户头像信息', |
||||
'db_table': 'user_img', |
||||
}, |
||||
), |
||||
] |
@ -0,0 +1,22 @@ |
||||
<!DOCTYPE html> |
||||
<html lang="en"> |
||||
<head> |
||||
<meta charset="UTF-8"> |
||||
<title>Upload Image</title> |
||||
</head> |
||||
<body> |
||||
<form enctype="multipart/form-data" action="" method="POST"> |
||||
{% csrf_token %} |
||||
{{ form_obj.as_p }} |
||||
<br> |
||||
<input type="submit" value="上传图片"> |
||||
{{ user_img }} |
||||
{% if user_img is not None %} |
||||
<div> |
||||
<img src="/media/{{ user_img.heading }}" alt=""> |
||||
</div> |
||||
{% endif %} |
||||
|
||||
</form> |
||||
</body> |
||||
</html> |
Loading…
Reference in new issue