├── 1 └── README.md /1: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.http import JsonResponse 3 | from django.views.decorators.csrf import csrf_exempt 4 | import json 5 | 6 | class Post(models.Model): 7 | title = models.CharField(max_length=100) 8 | content = models.TextField() 9 | 10 | @csrf_exempt 11 | def create_post(request): 12 | if request.method == "POST": 13 | data = json.loads(request.body) 14 | post = Post.objects.create(title=data['title'], content=data['content']) 15 | return JsonResponse({"message": "Post created", "post_id": post.id}) 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # -Blog-API 2 | Build a RESTful API for a blogging platform with CRUD operations, authentication, and comments. 3 | --------------------------------------------------------------------------------