File tree 10 files changed +61
-3
lines changed
10 files changed +61
-3
lines changed Original file line number Diff line number Diff line change 6
6
< title > Blog Page</ title >
7
7
< script >
8
8
const bloggit_conf = {
9
- "api_key" : "e9f51a0a6cc0494cb5525d9e8def7337 " ,
9
+ "api_key" : "7070aa3bfb7a4f6f8266fa44180d4aaf " ,
10
10
"cont_rend" :"classic" ,
11
11
"header" : {
12
12
"type" : "milky-way" ,
23
23
< script src ="https://code.jquery.com/jquery-3.5.1.slim.min.js "> </ script >
24
24
< script src ="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js "> </ script >
25
25
< script src ="
https://cdn.jsdelivr.net/npm/@popperjs/[email protected] /dist/umd/popper.min.js "
> </ script >
26
- <!-- <script src="./Javascript/home_and_blog.js"></script> -->
27
- < script src = "https://bloggit.pythonanywhere.com/static/Javascript/config.js "> </ script >
26
+ < script src ="./Javascript/home_and_blog.js "> </ script >
28
27
</ head >
29
28
< body >
30
29
< section id ="bloggit-header ">
Original file line number Diff line number Diff line change
1
+ from django .contrib import admin
2
+ from .models import Comment
3
+
4
+ # Register your models here.
5
+
6
+ class CommentAdmin (admin .ModelAdmin ):
7
+ list_display = ["post" ,'name' , "email" ]
8
+
9
+ admin .site .register (Comment , CommentAdmin )
Original file line number Diff line number Diff line change
1
+ from django .apps import AppConfig
2
+
3
+
4
+ class CommentsConfig (AppConfig ):
5
+ default_auto_field = "django.db.models.BigAutoField"
6
+ name = "comments"
Original file line number Diff line number Diff line change
1
+ from django .db import models
2
+ from tinymce .models import HTMLField
3
+ from api .models import Post
4
+
5
+ # Create your models here.
6
+
7
+ class Comment (models .Model ):
8
+ post = models .OneToOneField (Post , related_name = 'post' , on_delete = models .CASCADE )
9
+ name = models .CharField (max_length = 100 )
10
+ email = models .EmailField ()
11
+ comment = HTMLField ()
12
+
13
+ def __str__ (self ):
14
+ return str (self .post )
Original file line number Diff line number Diff line change
1
+ from rest_framework .serializers import ModelSerializer
2
+ from .models import *
3
+ from rest_framework .validators import ValidationError
4
+
5
+ class CommentSerializer (ModelSerializer ):
6
+ class Meta :
7
+ model = Comment
8
+ fields = "__all__"
9
+
10
+ def validate_comment (self , value ):
11
+ if value .strip () == "" :
12
+ raise ValidationError ("Comment can't be empty!" )
13
+ return value
Original file line number Diff line number Diff line change
1
+ from django .test import TestCase
2
+
3
+ # Create your tests here.
Original file line number Diff line number Diff line change
1
+ from django .shortcuts import render
2
+ from rest_framework .decorators import APIView
3
+ from rest_framework .generics import GenericAPIView
4
+ from rest_framework .permissions import AllowAny
5
+ from .serializers import *
6
+ from .models import *
7
+
8
+
9
+ # Create your views here.
10
+ class CommentView (GenericAPIView ):
11
+ serializer_class = CommentSerializer
12
+ queryset = Comment .objects .all ()
13
+ permission_classes = [AllowAny ]
Original file line number Diff line number Diff line change 43
43
'api' ,
44
44
"userprofile" ,
45
45
"app" ,
46
+ "comments" ,
46
47
47
48
48
49
# dependencies
You can’t perform that action at this time.
0 commit comments