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
# defining Custom Querysets methods for the manager | |
class StudentQuerySet(QuerySet): | |
def male(self): | |
return self.filter(gender='male') | |
def female(self): | |
return self.filter(gender='female') | |
def age_greater_or_equal_to(self, age): | |
return self.filter(age__gte=age) |
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
>>> Student.objects.get_males().get_students_age_less_or_equal(23) | |
Traceback (most recent call last): | |
File "<console>", line 1, in <module> | |
AttributeError: 'QuerySet' object has no attribute 'get_students_age_less_or_equal' |
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 student.models import Student | |
# Get the total number of students. | |
>>> student = Student.objects.get_total_students() | |
>>> student # 6 (ans according to the data in database) | |
# Get students with age less than or equal to the given age. | |
>>> student = Student.objects.get_students_age_less_or_equal(22) | |
>>> student # returns students with age less than or equal to the given age |
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.models import Manager, Q, Sum | |
from datetime import datetime | |
class StudentManager(Manager): | |
def get_total_students(self): | |
return self.all().count() | |
def get_students_age_less_or_equal(self, age): | |
return self.filter(age__lte=age) |
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 .managers import StudentManager, MaleManager, FemaleManager, StudentModifyManager, StudentQuerySet | |
from django.core.validators import MaxValueValidator | |
SEMESTER = ( | |
('sem1', 'sem1'), | |
('sem2', 'sem2'), | |
('sem3', 'sem3'), | |
('sem4', 'sem4'), | |
) |
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.contrib.auth.models import User | |
user = User.objects.get(id=1) |
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
; ================================ | |
; celery beat supervisor | |
; ================================ | |
; the name of your supervisord program | |
[program:voicechatproject_celery_beat] | |
; Set full path to celery program if using virtualenv | |
command=/home/er190622005/Botree/VoiceChat/chat_venv/bin/celery beat -A voicechatproject --loglevel=INFO |
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
; ================================== | |
; celery worker supervisor | |
; ================================== | |
; the name of your supervisord program | |
[program:voicechatproject_celery_worker] | |
; Set full path to celery program if using virtualenv | |
command=/home/er190622005/Botree/VoiceChat/chat_venv/bin/celery worker -A voicechatproject --loglevel=INFO |
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 botocore.exceptions import ClientError | |
from celery import task | |
from message.models import * | |
from celery.schedules import crontab | |
from celery.task import periodic_task | |
from django.db.models import Q | |
import datetime,boto3 | |
from django.conf import settings | |
from django.db import IntegrityError, transaction |
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
BROKER_URL = 'redis://localhost:6379' | |
CELERY_RESULT_BACKEND = 'redis://localhost:6379' | |
CELERY_ACCEPT_CONTENT = ['application/json'] | |
CELERY_TASK_SERIALIZER = 'json' | |
CELERY_RESULT_SERIALIZER = 'json' | |
CELERY_TIMEZONE = 'Asia/Calcutta' |