#2 Handling image upload
This commit is contained in:
parent
0f69c44cc3
commit
b0d9c46eb2
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
django_web_galleries/media/*
|
||||
django_web_galleries/static/*
|
@ -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
|
||||
)
|
@ -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'
|
||||
}
|
||||
|
@ -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
|
||||
)
|
Loading…
Reference in New Issue
Block a user