not required on pu
This commit is contained in:
parent
044eb472da
commit
e91f2bfbdf
@ -10,6 +10,15 @@ class CharacterSerializer(serializers.ModelSerializer):
|
||||
model = models.Character
|
||||
fields = ['id', 'name', 'description', 'sex', 'type', 'featured_image', 'featured_icon']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
request_method = self.context.get('request').method if self.context.get('request') else None
|
||||
|
||||
if request_method in ['PUT', 'PATCH']:
|
||||
# Jadikan optional di update
|
||||
self.fields['featured_image'].required = False
|
||||
self.fields['featured_icon'].required = False
|
||||
|
||||
class CharacterSkinSerializer(serializers.ModelSerializer):
|
||||
featured_image = ImageField(max_length=255, allow_empty_file=False)
|
||||
featured_icon = ImageField(max_length=255, allow_empty_file=False)
|
||||
|
||||
@ -22,7 +22,6 @@ from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
|
||||
urlpatterns = [
|
||||
# path('admin/', admin.site.urls),
|
||||
path('admin/', admin.site.urls),
|
||||
path('oauth/', include(oauth2_urls)),
|
||||
path('auth/', include('djoser.urls')),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user