9
9
def home (request ):
10
10
context_instance = RequestContext (request )
11
11
if request .method == 'GET' :
12
- data = Comments .objects .all ()
13
- comments = []
14
- for obj in data :
15
- commentCurr = {
16
- "user_id" : obj .user_id ,
17
- "comment" : obj .comment ,
18
- "post_id" : obj .post_id ,
19
- }
20
- comments .append (commentCurr )
21
- comments .append ({ 'status_code' : 'success' })
22
- return render_to_response ('index.html' , comments )
12
+ return render_to_response ('index.html' )
23
13
elif request .method == 'POST' :
24
14
data = request .POST .urlencode ()
25
15
comment = data .split ('&' )[0 ].split ('=' )[1 ]
@@ -30,17 +20,7 @@ def home(request):
30
20
post_id = '1' ,
31
21
comment = comment )
32
22
p1 .save ()
33
- data = Comments .objects .all ()
34
- comments = []
35
- for obj in data :
36
- commentCurr = {
37
- "user_id" : obj .user_id ,
38
- "comment" : obj .comment ,
39
- "post_id" : obj .post_id ,
40
- }
41
- comments .append (commentCurr )
42
- comments .append ({ 'status_code' : 'success' })
43
- return render_to_response ('index.html' , comments )
23
+ return render_to_response ('index.html' )
44
24
45
25
@csrf_exempt
46
26
def getComments (request ):
@@ -49,7 +29,7 @@ def getComments(request):
49
29
for obj in data :
50
30
commentCurr = {
51
31
"author" : obj .user_id ,
52
- "text" : obj .comment ,
32
+ "text" : obj .comment . replace ( '+' , ' ' ) ,
53
33
"post_id" : obj .post_id ,
54
34
}
55
35
comments .append (commentCurr )
0 commit comments