upload character pictures
This commit is contained in:
parent
59e783a4f7
commit
bd49b09896
|
@ -158,3 +158,5 @@ cython_debug/
|
||||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||||
#.idea/
|
#.idea/
|
||||||
|
|
||||||
|
media/
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Generated by Django 4.2.1 on 2023-08-24 18:43
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
("guild", "0010_playsessionsummaryversion"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name="character",
|
||||||
|
name="picture",
|
||||||
|
field=models.ImageField(
|
||||||
|
blank=True, null=True, upload_to="", verbose_name="Character Picture"
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -91,6 +91,10 @@ class Character(models.Model):
|
||||||
blank=True,
|
blank=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
picture = models.ImageField(
|
||||||
|
_("Character Picture"), null=True, blank=True, upload_to="uploads/"
|
||||||
|
)
|
||||||
|
|
||||||
created_at = models.DateTimeField(_("created at"), auto_now_add=True)
|
created_at = models.DateTimeField(_("created at"), auto_now_add=True)
|
||||||
updated_at = models.DateTimeField(_("updated at"), auto_now=True)
|
updated_at = models.DateTimeField(_("updated at"), auto_now=True)
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>{{character.description|md|safe}}</p>
|
<div class="row">
|
||||||
|
</div>
|
||||||
|
<a href="{{character.picture.url}}" style="float:left;margin-right:10px;margin-bottom:10px;">
|
||||||
|
<img src="{{character.picture.url}}" width="300"/>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<p>{{character.description|md|safe}}</p>
|
||||||
|
<div class="column">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
<h2>Session History</h2>
|
<h2>Session History</h2>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<form action="" method="post">
|
<form action="" method="post" enctype="multipart/form-data" >
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form.as_p }}
|
{{ form.as_p }}
|
||||||
{% if object %}
|
{% if object %}
|
||||||
|
|
|
@ -12,7 +12,7 @@ class CharacterListView(LoginRequiredMixin, ListView):
|
||||||
|
|
||||||
class CreateCharacterView(LoginRequiredMixin, CreateView):
|
class CreateCharacterView(LoginRequiredMixin, CreateView):
|
||||||
model = Character
|
model = Character
|
||||||
fields = ["name", "description", "player", "status"]
|
fields = ["name", "picture", "description", "player", "status"]
|
||||||
|
|
||||||
|
|
||||||
class CharacterDetailView(LoginRequiredMixin, DetailView):
|
class CharacterDetailView(LoginRequiredMixin, DetailView):
|
||||||
|
@ -33,7 +33,7 @@ class CharacterDetailView(LoginRequiredMixin, DetailView):
|
||||||
|
|
||||||
class CharacterUpdateView(LoginRequiredMixin, UpdateView):
|
class CharacterUpdateView(LoginRequiredMixin, UpdateView):
|
||||||
model = Character
|
model = Character
|
||||||
fields = ["name", "description", "player", "status"]
|
fields = ["name", "picture", "description", "player", "status"]
|
||||||
|
|
||||||
|
|
||||||
class CharacterDeleteView(LoginRequiredMixin, DeleteView):
|
class CharacterDeleteView(LoginRequiredMixin, DeleteView):
|
||||||
|
|
|
@ -20,3 +20,7 @@ DATABASES = {
|
||||||
"NAME": BASE_DIR / "db.sqlite3",
|
"NAME": BASE_DIR / "db.sqlite3",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MEDIA_ROOT = BASE_DIR / "media"
|
||||||
|
MEDIA_URL = "/media/"
|
||||||
|
|
|
@ -24,3 +24,6 @@ DATABASES = {
|
||||||
"NAME": "/data/db.sqlite3",
|
"NAME": "/data/db.sqlite3",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EDIA_ROOT = "/data/guild_journal/media"
|
||||||
|
MEDIA_URL = "/media/"
|
||||||
|
|
|
@ -16,8 +16,11 @@ Including another URLconf
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import include, path
|
from django.urls import include, path
|
||||||
|
from django.conf import settings
|
||||||
|
from django.conf.urls.static import static
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path("", include(("guild.urls", "guild"), namespace="guild")),
|
path("", include(("guild.urls", "guild"), namespace="guild")),
|
||||||
]
|
]
|
||||||
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
|
Loading…
Reference in New Issue