Wednesday, February 28, 2018

Help needed - new very first django App

Hi All,

I am very new to django framework ( just 2 days)
I am referring django tutorial pdf for my self learning.
Right now I am stuck at my very first program using Django Template Language (DTL) .

Please find the below code just for your reference:

urls.py  ( Application )
---------
from django.urls import path
from . import views

urlpatterns = [
               path('dispWelcomePage/', views.myWelcomepage, name='myWelcomepage'),
      path('secondPage/', views.mySecondpage),
      path('pagenum/', views.dispInputParam),
               path('exRender/',views.exampleRenderFunc),
      path('exRenderDict/',views.passDictValues)
               ]
     
     
     
views.py  ( Application )
----------
from django.shortcuts import render
from django.http import HttpResponse

def passDictValues(request):
    mylist=['a','b','c','d']
    empDetails={'name':'ABCD','city':'xyz','age':'30','gender':'M','MyListArg':mylist}
    return render(request,'myapp/RenderDictParams.html',empDetails)

  
RenderDictParams.html:
--------------------------------
<html>
<body>
   <h3>This is Render Method Example with Python Dictionary as Arguments!! </h3>
   Testing_1<br>
   {% for val in mylist %}
    {{ val }}
   {% endfor %}  
   Testing_2
   </body>
</html>


When running the url  http://127.0.0.1:8000/myapp/exRenderDict/ output doesn't display the values which is from the for loop.
(Please find the attached file just for you reference )
My django verion : 2.0.1
Python version : 3.6.0
Please you help me if possible to sort out this.
Let me know if I am missing anything or any further details needed.

Thanks for your support
Regards
JayaramN




--
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-users@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/c856d337-928e-4c04-9471-ac4caab2b80b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment