Hi my friends,
I wanna make simple example in order to understand some basics, so
I made these steps
- First i create file as a name Prusa
- Startproject mysite
- Startapp register
- runserver and everything is ok
- i made register/templates file and made settings.py arrangement
- i created two ile under templates index.html and about.html
- first i create this model on models.py
from django.db import models
# Create your models here.
class Patient(models.Model):
name = models.CharField(max_length=100)
surname = models.CharField(max_length=100)
ilness = models.CharField(max_length=200)
- views.py i made this codes
from django.shortcuts import render
from django.http import HttpResponse
from .models import Patient
# Create your views here.
def About(request):
return render(request, 'about.html')
def Anasayfa(request):
return render(request, 'index.html')
def Doctor(request):
post = Patient.object.all()
return render(request, 'index.html', {'post': post})
- register.urls.py i made these codes
from django.urls import path
from .views import About, Anasayfa
urlpatterns = [
path('', Anasayfa, name='index'),
path('about/', About, name='about'),
]
- mysite.urls.py i made these codes
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('register.urls')),
]
- register.admin.py file i made these codes
from django.contrib import admin
from .models import Patient
# Register your models here.
admin.site.register(Patient)
- templates/index.html i made these codes
<h1>Hello</h1>
<div>
{% for post in posts %}
<div>
<p>{{ post.name }}</p>
</div>
{% endfor %}
</div>
After all when i runserver
i see only hello , but i expect see the patient name,
i created super user and i added 2 patient form django admin panel but, i see nothing except Hello .
How can i see patient names under the Hello word?



