TemplateDoesn'tExist...Door error...

Asked 2 years ago, Updated 2 years ago, 51 views

I'm making a similar web after watching the Jango Tutorial http://ssy10011218.pythonanywhere.com/ webpage. If you press the text here, it goes into the post_detail, and what looks like a pencil is the correction button.

But when I press the modify button, it says that the template does not exist...

#post_detail.html.
<div class="post">
        <div class="date">
            {{ {{ post.pub_date }}
        </div>

        <h1>{{ post.product }} <a class="btn btn-default" href="{% url 'post_edit' pk=post.pk %}"><span class="glyphicon glyphicon-pencil"></span></a></h1>
        <p>{{ post.description|linebreaksbr }}</p>

    </div>
#Some of views.py
def post_edit(request, pk):
    post = get_object_or_404(Post, pk=pk)
    if request.method == "POST":
        form = PostForm(instance=post)
        if form.is_valid():
            post = form.save(commit=False)
            post.seller = request.user
            post.pub_date= timezone.now()
            post.save()
            return redirect('mysite/views.post_detail',pk=post.pk)
    else:
       form = PostForm(instance = post)
    return render(request, 'mysite/post_edit.html',{'form':form})
#post_edit.html.
<h1>New post</h1>
    <form method="POST" class="post-form">{% csrf_token %}
        {{ {{ form.as_p }}
        <button type="submit" class="save btn btn-default">Save</button>
    </form>

It doesn't look like a problem just by looking at the cancer, what should I do? ㅠ<

django

2022-09-22 21:15

2 Answers

The error TemplateDoesNotExistat / is literally because the path does not have a template.

Is the file mysite/post_edit.html in its path?


2022-09-22 21:15

The template must exist in the mysite/templates/mysite/post_edit.html path.

Django's Template Loader includes App Directory Loader and File System Loader. This corresponds to the App Directory Loader.


2022-09-22 21:15

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.