mirror of
https://github.com/lemeow125/DRF_Template.git
synced 2024-11-17 04:09:25 +08:00
Fix development url for media files
This commit is contained in:
parent
5f4aac696e
commit
55f16b15fe
3 changed files with 6 additions and 10 deletions
|
@ -19,7 +19,7 @@ class CustomUser(AbstractUser):
|
|||
null=True, upload_to='avatars/')
|
||||
|
||||
def avatar_url(self):
|
||||
return f'/api/v1/media/avatars/{self.avatar.name}'
|
||||
return f'/api/v1/media/avatars/{self.avatar.field.storage.name(self.avatar.path)}'
|
||||
|
||||
@property
|
||||
def full_name(self):
|
||||
|
@ -29,9 +29,6 @@ class CustomUser(AbstractUser):
|
|||
def admin_url(self):
|
||||
return reverse('admin:users_customuser_change', args=(self.pk,))
|
||||
|
||||
def get_prep_value(self, value):
|
||||
original_filename = self.avatar.field.storage.name(self.avatar.path)
|
||||
return original_filename
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
from django.conf.urls.static import static
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
from django.urls import path, include
|
||||
from config import settings
|
||||
urlpatterns = [
|
||||
path('accounts/', include('accounts.urls')),
|
||||
|
||||
]
|
||||
if settings.DEBUG:
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
from django.conf.urls.static import static
|
||||
|
||||
# Media files
|
||||
# Media files
|
||||
if settings.DEBUG:
|
||||
urlpatterns += staticfiles_urlpatterns()
|
||||
urlpatterns += static(
|
||||
settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
'media/', document_root=settings.MEDIA_ROOT)
|
||||
|
|
|
@ -93,7 +93,6 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static')
|
|||
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
|
||||
MEDIA_URL = 'api/v1/media/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||
|
||||
ROOT_URLCONF = 'config.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
|
|
Loading…
Reference in a new issue