I want to exclude specific column in rest framework only for view data. (not for put data)
[models.py]
class article(models.Model):
articleNo = models.AutoField(primary_key=True)
userkey = models.CharField(max_length=50, null=False)
content = models.CharField(max_length=500, null=False)
password = models.CharField(max_length=20, null=False, default='1234')
date = models.DateTimeField(auto_now_add=True)
[serializers.py]
class articleSerializer(serializers.ModelSerializer):
class Meta:
model = article
fields = ('articleNo', 'userkey', 'content', 'password', 'date')
After I change fields = ('articleNo', 'content', 'date') from serializers.py,
Only articleNo, content, date will be show in rest framework.
But, When I PUT data to article, It doesn't inserted properly.
After insert data, MySQL data is below.
articleNo|content | date |userkey |password
37 | Test | 2018-03-13 08:01:07.424564 | | 1234
userkey is blank and password is default value.
Maybe I have to modify serializers.py I think, But I don't know how to fix it.
How can I insert data properly?
PEP8correct python variable name will bearticle_noand notarticleNo