Skip to content

Commit

Permalink
add event images (#33)
Browse files Browse the repository at this point in the history
Co-authored-by: guoshijiang <[email protected]>
  • Loading branch information
guoshijiang and guoshijiang authored Mar 24, 2024
1 parent 7ef6e7c commit ef67b52
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
18 changes: 18 additions & 0 deletions website/migrations/0003_event_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.1.1 on 2024-03-24 06:36

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('website', '0002_blog_cat'),
]

operations = [
migrations.AddField(
model_name='event',
name='image',
field=models.ImageField(blank=True, null=True, upload_to='event/%Y/%m/%d/'),
),
]
6 changes: 6 additions & 0 deletions website/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ class Event(BaseModel):
unique=False,
verbose_name='事件名称'
)
image = models.ImageField(
upload_to='event/%Y/%m/%d/',
blank=True,
null=True
)
link_url = models.CharField(
default="",
max_length=100,
Expand All @@ -159,6 +164,7 @@ def as_dict(self):
return {
'id': self.id,
'name': self.name,
'image': str(self.image),
'link': self.link_url,
'describe': str(self.describe),
'created_at': self.created_at.astimezone(tz).strftime("%Y-%m-%d %H:%M:%S")
Expand Down

0 comments on commit ef67b52

Please sign in to comment.