-
Notifications
You must be signed in to change notification settings - Fork 1
Tutorial on Django Models
Mücahit Erdoğan Ünlü edited this page May 15, 2024
·
1 revision
- You can define a field such as text or pub_date.
class Post(models.Model):
text = models.CharField(max_length=200)
pub_date = models.DateTimeField('Publication Date', auto_now=True)
def get_readable_date(self):
return self.pub_date.strftime("%B %d, %Y")
- you can create a method to use in your serializer as source such as get_readable_date() as above. By setting read only to True, user is not allowed to edit it. Use this as source in serializer:
class PostSerializer(serializers.ModelSerializer):
pub_date = serializers.CharField(source = 'get_readable_date', read_only = True)
class Meta:
model = Post
fields = ["pub_date"]
Turquiz App
DONE
- Lab Report #1
- Lab Report #2
- Lab Report #3
- Lab Report #4
- Lab Report #5
- Lab Report #6
- Lab Report #7
- Lab Report for Lab 9
- Lab Meeting #1
- Meeting #1
- Lab Meeting #2
- Meeting #2
- Project Plan Meeting
- Frontend Meeting #1
- Lab Meeting #3
- Meeting #3
- Meeting #4
- Lab Meeting #4
- Meeting #5
- Meeting #6
- Meeting #7
- Meeting #8
- User Scenario 1 - Explore and Register
- User Scenario 2 - Search for a Quiz & Create a Quiz
- User Scenario 3 - Take & Review a Quiz
- User Scenario 4 - Search Forum & Bookmark & Upvote & Answer
- User Scenario 5 - User Badges
- User Scenario Template
- User Stories