#2 Handling image upload

This commit is contained in:
reverend 2022-12-25 12:19:54 +01:00
parent 0f69c44cc3
commit b0d9c46eb2
4 changed files with 19 additions and 10 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
django_web_galleries/media/*
django_web_galleries/static/*

View File

@ -16,7 +16,20 @@ Including another URLconf
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('web_galleries.urls'))
]
if settings.DEBUG:
urlpatterns += static(
settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT
)
urlpatterns += static(
settings.STATIC_URL,
document_root=settings.STATIC_ROOT
)

View File

@ -6,4 +6,7 @@ from .models import Image
class ImageUploadForm(forms.ModelForm):
class Meta:
model = Image
fields = ['description', 'image_file', 'private']
fields = ['description', 'image_file', 'private', 'title']
labels = {
'private': 'Make this image private'
}

View File

@ -1,6 +1,4 @@
from django.urls import path
from django.conf import settings
from django.conf.urls.static import static
from .views import (
ImageUploadView,
@ -11,9 +9,3 @@ urlpatterns = [
path('', PublicImageListView.as_view(), name='home'),
path('upload/', ImageUploadView.as_view(), name='upload_image')
]
if settings.DEBUG:
urlpatterns += static(
settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT
)