Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

views.py django

from django.http import HttpResponse


def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")
Comment

views django

from django.http import HttpResponse
import datetime

def current_datetime(request):
    now = datetime.datetime.now()
    html = "<html><body>It is now %s.</body></html>" % now
    return HttpResponse(html)
Comment

Views.py


from urllib import request

from django.contrib import messages
from django.db import IntegrityError
from django.shortcuts import render, redirect, get_object_or_404
from django.template import context

from pos.models import category
# Create your views here.
def admindashbord(request):
    return render(request, "homepage.html")
def docs(request):
    return render(request,"docs.html")
def order(request):
    return render(request,"orders.html")
# In page menue
def medicine(request):
    return render(request, "Medicene.html")

# In page menue / add_category
def addCategory(request):
    return render(request, "Category/ADD_category.html")
def store(request):
    try:
        col=category()
        col.categoryName=request.POST["genre"]
        col.save()
        messages.success(request, "Add successfully")
    except IntegrityError:
        messages.error(request, "Already exists")
    return redirect("add_category")
# In page menue / update_category
def updateCategory(request):
    return render(request, "Category/Update_category.html")
def update(request,id):
    try:
        col = category.objects.get(pk=id)
        context={
            "category":col
        }
    except Exception as ex:
        print(ex)
    return redirect("updatecategory",context)
# In page menue / delete_category
def delete(request,id):
    try:
        if request.method == "GET":
            col = category.objects.filter(id=id)
            col.delete()
    except Exception as ex:
        print(ex)
    return redirect("category")
def Category(request):
    Category = category.objects.all()
    context = {"categorys": Category}
    return render(request, "Category/category.html", context)
# In page menue / add_product
def addProduct(request):
    return render(request, "ADD_Product.html")
# External Menue
def login(request):
    return render(request, "login.html")
def sigin(request):
    return render(request, "signup.html")
def resetPass(request):
    return render(request, "reset-password.html")
def Error404(request):
    return render(request, "404.html")
#chart
def chart(request):
    return render(request, "charts.html")
# Help
def help(request):
    return render(request, "help.html")
# setting
def setting(request):
    return render(request, "settings.html")
# Account
def account(request):
    return render(request, "account.html")
# Notificate
def notificate(request):
    return render(request, "notifications.html")
Comment

views.py

def updateCategory(request):
    return render(request, "Category/Update_category.html")
def update(request,id):
    try:
        col = category.objects.get(pk=id)
        context={
            "category":col
        }
    except Exception as ex:
        print(ex)
    return redirect("updatecategory",context)
Comment

PREVIOUS NEXT
Code Example
Python :: messagebox python pyqt 
Python :: python package for confluence 
Python :: qt designer messagebox python 
Python :: install python3 in ubuntu 
Python :: dot operator in python 
Python :: number of spaes pythopn 
Python :: np.reshape() 
Python :: filter dict by list of keys python 
Python :: How to Get the Intersection of Sets in Python 
Python :: How do I iterate over a subfolder in Python 
Python :: generate random int python 
Python :: discordpy owner only command 
Python :: download image from url python requests 
Python :: translate french to english 
Python :: python get github file content 
Python :: python string cut first n characters 
Python :: selenium webdriver options python 
Python :: django message 
Python :: numpy create array with values in range 
Python :: how to find the path of a python module 
Python :: inplace pandas 
Python :: python get column from grouped dataframe 
Python :: find next multiple of 5 python 
Python :: vscode in browser github 
Python :: How to Adjust Title Position in Matplotlib 
Python :: installation of uvicorn for fastapi 
Python :: python set with counts 
Python :: get the list of column names whose data type is float python 
Python :: python dictionary sort by value then alphabetically 
Python :: python string to list new line 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =