Bismillah
I want to create edit student
was search , found django girls,
copied few code snippets
to help in coding
Refernce :
https://tutorial.djangogirls.org/en/django_forms/
https://docs.djangoproject.com/en/2.2/topics/forms/
blog/templates/blog/post_detail.html
blog/templates/blog/post_detail.html
{% extends 'blog/base.html' %}
{% block content %}
{% if post.published_date %}
{{ post.published_date }}
{% endif %}I want to create edit student
was search , found django girls,
copied few code snippets
to help in coding
Refernce :
https://tutorial.djangogirls.org/en/django_forms/
https://docs.djangoproject.com/en/2.2/topics/forms/
blog/templates/blog/post_detail.html
blog/templates/blog/post_detail.html
{% extends 'blog/base.html' %}
{% block content %}
{% if post.published_date %}
{{ post.published_date }}
{{ post.title }}
{{ post.text|linebreaksbr }}
{% endblock %}
blog/urls.py
path('post/
def post_edit(request, pk):
post = get_object_or_404(Post, pk=pk)
if request.method == "POST":
form = PostForm(request.POST, instance=post)
if form.is_valid():
post = form.save(commit=False)
post.author = request.user
post.published_date = timezone.now()
post.save()
return redirect('post_detail', pk=post.pk)
else:
form = PostForm(instance=post)
return render(request, 'blog/post_edit.html', {'form': form})
blog/templates/blog/base.html
{% if user.is_authenticated %}
{% endif %}
blog/templates/blog/post_detail.html
{% if user.is_authenticated %}
{% endif %}
command-line
$ git status
$ git add --all .
$ git status
$ git commit -m "Added views to create/edit blog post inside the site."
$ git push
Then, in a PythonAnywhere Bash console:
PythonAnywhere command-line
$ cd ~/
$ git pull
[...]
No comments:
Post a Comment