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.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 :: python with example 
Python :: display pil image on kivy canvas 
Python :: duplicate a list with for loop in python 
Python :: python import as 
Python :: python pandas dataframe conditional subset 
Python :: python cartesian coordinates code 
Python :: dimension of an indez pandas 
Python :: parse xml in python 
Python :: count items in list python by loop 
Python :: pandas assign multiple columns at once 
Python :: python binary float 
Python :: assert with message python 
Python :: how to get csv file first row first column value in python 
Python :: pandas remove multi header from dataframe 
Python :: pandas dataframe apply 
Python :: how to make an array python 
Python :: Python - How To Concatenate List of String 
Python :: pandas filter by dictionary 
Python :: how to get quarter year date in pandas 
Python :: python redis delete many 
Python :: adding numbers with numbers. python 
Python :: use argparse to call function and use argument in function 
Python :: Python re.subn() 
Python :: base64 python flask html 
Python :: pyqt matplotlib 
Python :: post from postman and receive in python 
Python :: dependency injection python 
Python :: how to check how many key value pairs are in a dict python 
Python :: py array contains 
Python :: python change all values in nested list 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =