با سلام و عرض ادب خدمت دوستان
من ی سوال داشتم اونم اینکه من طبق آموزش استاد پیش میرم ولی ی مشکلی دارم که کل کارم رو مختل
کرده اونم اینه که وقتی که یک تابع میسازم و رندر میگیرم و میخوام ی سری اطلاعاتی رو که داخل اون تابع
هست رو داخل فایل HTML وارد کنم و داخل صفحه بالا بیارم، اون موقع به مشکل میخورم به عنوان مثال :
{"Myname":"Taha"} این رو وقتی داخل فایل HTML میزارم بجای Taha این نوشته {{ Myname }} رو به
همین فرم نشون میده. نمیدونم اشکال کار از کجاست؟؟؟
این کد پایتون:
from django.http import HttpResponse
from django.shortcuts import render
def home_page(request):
contex = {
"fullname": "Taha Gholami",
"Explain": "This is my First Page"
}
return render(request, "home_page.html", contex)
# return HttpResponse("This is Main Page")
def about_us(request):
return HttpResponse("This Page Tells about us")اینم کد HTML:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>سایت پایگاه صفحه اصلی</title>
<!-- Bootstrap -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="text-center text-info">
<h1>Hello {{ fullname }}</h1>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</body>
</html>اینم نتیجه:
