The hierarchy is as follows.
mysite(startproject)
|__setting.py
|__urls.py
|__model.py
manage.py
db.sqlite3
blog(app)
|__views.py
|__urls.py
|__wsgi.py
Write the source code in views.py. You can get the text in the form ** with ** form.cleaned_data **. At this stage, it is ** dictionary type ** and the key is text, so you can get it with ** form.cleaned_data ['text'] **.
blog/views.py
def article_edit(request, pk):
post = get_object_or_404(Article, pk=pk)
if request.method == "POST":
form = ArticleForm(request.POST, instance=post)
if form.is_valid():
#Display debug messages on the console using logging.
logging.debug(form.cleaned_data['text'])
post = form.save(commit=False)
post.author = request.user
post.published_date = timezone.now()
post.save()
return redirect('article_detail', pk = post.pk)
else:
form = ArticleForm(instance=post)
return render(request, 'blog/article_edit.html', {'form' : form})
If you cannot display the debug message, refer to the following.
How to print debug messages to the Django console http://qiita.com/NoriakiOshita/items/7716c6e46338768467eb
Recommended Posts