This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db import models | |
| from django.contrib.auth.models import AbstractBaseUser, BaseUserManager | |
| class MyAccountManager(BaseUserManager): | |
| def create_user(self, email, username, password=None): | |
| if not email: | |
| raise ValueError('Users must have an email address') | |
| if not username: | |
| raise ValueError('Users must have a username') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def index(request): | |
| products = Product.objects.all() | |
| if request.method == "POST": | |
| Check = request.POST.getlist('checking') | |
| quan = request.POST.getlist('quan') | |
| # concurrent list | |
| newQuan = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.shortcuts import render | |
| from django.views.generic import View | |
| from upload.forms import UploadForm | |
| from django.http import JsonResponse | |
| # Create your views here. | |
| class HomeView(View): | |
| def get(self, request): | |
| form = UploadForm() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django import forms | |
| from upload.models import Upload | |
| class UploadForm(forms.ModelForm): | |
| class Meta: | |
| model = Upload | |
| fields = ['title', 'image'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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.0"> | |
| <title>Document</title> | |
| <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" | |
| integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous"> | |
| <!-- Latest compiled and minified JavaScript --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Upload(models.Model): | |
| title = models.CharField(max_length=50) | |
| image = models.ImageField() | |
| def __str__(self): | |
| return self.title |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @receiver(m2m_changed, sender=Order.order_name.through) | |
| def checkquan(sender, instance, **kwargs): | |
| print("Working") | |
| prod = instance.order_name.all() | |
| for p in prod: | |
| p.quantity -= instance.order_quantity | |
| p.save() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.core.management.base import BaseCommand | |
| from django.utils import timezone | |
| class Mycommand(BaseCommand): | |
| help = 'Test if custom command is working or not' | |
| def handle(self, *args, **kwargs): | |
| self.stdout.write("Hi all set, it is working.") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Type 'manage.py help <subcommand>' for help on a specific subcommand. | |
| Available subcommands: | |
| [auth] | |
| changepassword | |
| createsuperuser | |
| [contenttypes] | |
| remove_stale_contenttypes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ............... | |
| <a href="{% url 'users_csv' %}">Export CSV</a> | |
| ............... |