Project name-djangoTut
app name-Home
My urls.py file of Home app:
My views.py file of Home app:
My home/home.html file:
For more such stuffs comment below ...
app name-Home
My urls.py file of Home app:
#functions to import
from django.urls import path
from home.views import HomeView
from django.conf.urls import url
app_name='home'
urlpatterns = [
path('',HomeView.as_view(),name='home'),
]
My views.py file of Home app:
#functions to import
from django.views.generic import TemplateView
from django.shortcuts import render
from django.contrib.auth.models import User
#class associated with url
class HomeView(TemplateView):
template_name='home/home.html'
def get(self,request):
users=User.objects.exclude(id=request.user.id)
args={'users':users}
return render(request,self.template_name,args)
My home/home.html file:
{% comment %} extending the base.html file in ginger templating language
{% endcomment %}{% extends 'base.html' %}
{% block body %}
<div class="container">
<h2>Other Peoples</h2>
{% for user in users %}
<h3>{{user.username}}</h3>
{% endfor %}
</div>
{% endblock body %}
For more such stuffs comment below ...
No comments:
Post a Comment
Please do not enter any spam link in the comment box