#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/media/*
|
||||||
|
django_web_galleries/static/*
|
@ -16,7 +16,20 @@ Including another URLconf
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path, include
|
from django.urls import path, include
|
||||||
|
|
||||||
|
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('web_galleries.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 ImageUploadForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Image
|
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.urls import path
|
||||||
from django.conf import settings
|
|
||||||
from django.conf.urls.static import static
|
|
||||||
|
|
||||||
from .views import (
|
from .views import (
|
||||||
ImageUploadView,
|
ImageUploadView,
|
||||||
@ -11,9 +9,3 @@ urlpatterns = [
|
|||||||
path('', PublicImageListView.as_view(), name='home'),
|
path('', PublicImageListView.as_view(), name='home'),
|
||||||
path('upload/', ImageUploadView.as_view(), name='upload_image')
|
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