Skip to content

Commit

Permalink
9.CREATE - GET & POST
Browse files Browse the repository at this point in the history
  • Loading branch information
egoing committed Dec 8, 2021
1 parent 0adefbf commit db47097
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion myapp/views.py
@@ -1,4 +1,5 @@
from django.shortcuts import render, HttpResponse
from django.views.decorators.csrf import csrf_exempt

topics = [
{'id':1, 'title':'routing', 'body':'Routing is ..'},
Expand Down Expand Up @@ -41,9 +42,10 @@ def read(request, id):
article = f'<h2>{topic["title"]}</h2>{topic["body"]}'
return HttpResponse(HTMLTemplate(article))

@csrf_exempt
def create(request):
article = '''
<form action="/create/">
<form action="/create/" method="post">
<p><input type="text" name="title" placeholder="title"></p>
<p><textarea name="body" placeholder="body"></textarea></p>
<p><input type="submit"></p>
Expand Down

0 comments on commit db47097

Please sign in to comment.