Django 2.0 Tutorial Template

৭৪টি ভিউ
প্রথম অপঠিত মেসেজটিতে চলে আসুন

Carl Brubaker

পড়া হয়নি,
৯ ডিসে, ২০১৭, ৪:৪৪:৫০ PM৯/১২/১৭
প্রাপক Django users
I'm not sure what is wrong, but my template doesn't load correctly. Instead of what I'm supposed to see I get this in my web browser:

<ul>

   

        <li><a href="/polls/1/">What yo?</a></li>

   

    </ul>



Help please!

Dylan Reinhold

পড়া হয়নি,
৯ ডিসে, ২০১৭, ৪:৫০:৩৭ PM৯/১২/১৭
প্রাপক django...@googlegroups.com
Show us your template.

Dylan

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5f0061c6-5cf6-4050-98f4-64d52a307d13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Carl Brubaker

পড়া হয়নি,
৯ ডিসে, ২০১৭, ৯:০৫:৫৫ PM৯/১২/১৭
প্রাপক Django users
I copied it from the django tutorial page:

{% if latest_question_list %}
    <ul>
    {% for question in latest_question_list %}
        <li><a href="/polls/{{ question.id }}/">{{ question.question_text }}</a></li>
    {% endfor %}
    </ul>
{% else %}
    <p>No polls are available.</p>
{% endif %}


Dylan Reinhold

পড়া হয়নি,
৯ ডিসে, ২০১৭, ১১:৫১:২১ PM৯/১২/১৭
প্রাপক django...@googlegroups.com
That looks fine. how about your view.py.

Dylan

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Matthias Müller

পড়া হয়নি,
১০ ডিসে, ২০১৭, ৫:৫৭:১১ AM১০/১২/১৭
প্রাপক django...@googlegroups.com
It look s fine also to me. What do you expect ?

Kavie Mo

পড়া হয়নি,
১০ ডিসে, ২০১৭, ৯:০৪:৫৯ AM১০/১২/১৭
প্রাপক Django users
What do you mean by not loading correctly?
is it a problem of your urls.py setting?

Carl Brubaker

পড়া হয়নি,
১০ ডিসে, ২০১৭, ৩:২৭:৪৭ PM১০/১২/১৭
প্রাপক Django users
Code for my view.py

from django.shortcuts import render
from django.http import HttpResponse
from django.http import Http404
from django.shortcuts import render
from django.template import loader

from .models import Question

# Create your views here.
def index(request):
    latest_question_list = Question.objects.order_by('-pub_date')[:5]
    template = loader.get_template('polls/index.html')
    context = {
        'latest_question_list': latest_question_list,
    }
    return HttpResponse(template.render(context, request))

def detail(request, question_id):
    return HttpResponse("You're looking at question %s." % question_id)

def results(request, question_id):
    response = "You're looking at the results of question %s."
    return HttpResponse(response % question_id)

def vote(request, question_id):
    return HttpResponse("You're voting on question %s." % question_id)



According to the tutorial, I'm supposed to have: "Load the page by pointing your browser at “/polls/”, and you should see a bulleted-list containing the “What’s up” question from Tutorial 2. The link points to the question’s detail page." which I'm not seeing.

Roberth Solis Martínez

পড়া হয়নি,
১০ ডিসে, ২০১৭, ৫:৫২:৩০ PM১০/১২/১৭
প্রাপক Django users
I think its better if you use:

context = {
        'latest_question_list': latest_question_list,
}

return render(request, 'polls/index.html', context)

Carl Brubaker

পড়া হয়নি,
১০ ডিসে, ২০১৭, ৬:১৩:৫২ PM১০/১২/১৭
প্রাপক Django users
Tried that one too, as it is further down in the tutorial. Still the same result.

Carl Brubaker

পড়া হয়নি,
১০ ডিসে, ২০১৭, ৬:৫৩:০৫ PM১০/১২/১৭
প্রাপক Django users
Alright, so I found out the my text editor was saving my files incorrectly. Even though it had ".html" it was displaying the whole text in the web browser, instead of interpreting the the code.
সকলকে উত্তর দিন
লেখককে লিখে পাঠান
ফরওয়ার্ড করুন
0টি নতুন মেসেজ