Re: django queryset - Get the data particular to current year only

2022-04-02 Thread Lalit Suthar
I think this is related to your query
https://stackoverflow.com/a/28101722/8882295

On Thu, 31 Mar 2022 at 11:22, Trippy Samurai 
wrote:

>
> 
>
> I have my query written to get some thing from database and display on my
> website that query is getting all the data from db but what if i want to
> get the data particular to current year only
>
>
> def get(self, request, *args, **kwargs):
> filters = self.get_filters()
>
> result = Model.objects.all().filter(*filters).distinct().aggregate(
> t=Sum('t'),
> b=Sum('b'),
> )
>
> result2 = Model.objects.all().filter(*filters).distinct().aggregate(
> past_due=Sum('balance', filter=Q(due_date__lt=timezone.now()))
> )
>
> zero = Decimal('0.00')
>
> total = result['t'] or zero
> balance = result['b'] or zero
> past_due = result2['past_due'] or zero
> amount_received = t - b
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f0959467-786f-4701-9d68-abd2e54c3aaan%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGp2JVGoatg_BEPt-jYQVD7_%3DURdhraY%3D8KWvrL40yBJ0vYSSg%40mail.gmail.com.


Re: runserver not working

2022-04-02 Thread Heman Okumbo
Ensure that your manage.py file  on your settings folder has the right
syntax as shown.

On Tue, Mar 22, 2022, 08:07 'Delvin Alexander' via Django users <
django-users@googlegroups.com> wrote:

> would anyone know why my "manage.py runserver" is not working?
>
> Every time i try running it on the command prompt, i get relocated to my
> visual studio of manage.py file that states this:
>
> #*!/usr/bin/env python*
> *"""Django's command-line utility for administrative tasks."""*
> *import os*
> *import sys*
>
>
> *def main():*
> *"""Run administrative tasks."""*
> *os.environ.setdefault('DJANGO_SETTINGS_MODULE',
> 'django_project.settings')*
> *try:*
> *from django.core.management import execute_from_command_line*
> *except ImportError as exc:*
> *raise ImportError(*
> *"Couldn't import Django. Are you sure it's installed and "*
> *"available on your PYTHONPATH environment variable? Did you "*
> *"forget to activate a virtual environment?"*
> *) from exc*
> *execute_from_command_line(sys.argv)*
>
>
> *if __name__ == '__main__':*
> *main()*
>
>
> A step in the right direction will be super helpful for me.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/69291c68-61e7-4557-8175-7b705bcfcbb0n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJt9CbgeTKVtcuiARCtiGmHu-8-7nP3cFc4Wjdq0yqxbu80-oA%40mail.gmail.com.


Re: runserver not working

2022-04-02 Thread Gabriel Araya Garcia
Did you solve that. If not, you could tell me and I'll help you

Gabriel Araya Garcia
GMI - Desarrollo de Sistemas Informáticos




El mar, 22 mar 2022 a las 2:07, 'Delvin Alexander' via Django users (<
django-users@googlegroups.com>) escribió:

> would anyone know why my "manage.py runserver" is not working?
>
> Every time i try running it on the command prompt, i get relocated to my
> visual studio of manage.py file that states this:
>
> #*!/usr/bin/env python*
> *"""Django's command-line utility for administrative tasks."""*
> *import os*
> *import sys*
>
>
> *def main():*
> *"""Run administrative tasks."""*
> *os.environ.setdefault('DJANGO_SETTINGS_MODULE',
> 'django_project.settings')*
> *try:*
> *from django.core.management import execute_from_command_line*
> *except ImportError as exc:*
> *raise ImportError(*
> *"Couldn't import Django. Are you sure it's installed and "*
> *"available on your PYTHONPATH environment variable? Did you "*
> *"forget to activate a virtual environment?"*
> *) from exc*
> *execute_from_command_line(sys.argv)*
>
>
> *if __name__ == '__main__':*
> *main()*
>
>
> A step in the right direction will be super helpful for me.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/69291c68-61e7-4557-8175-7b705bcfcbb0n%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKVvSDAZXjmAX5wTAardff29U2CM9q78-5UdDBZjTSv_2vZy%2BA%40mail.gmail.com.


Django admin Ordering the display

2022-04-02 Thread Ali Hamza
How i Order this field descending order. i want completeorders show first 
then completemodules
[image: DeepinScreenshot_select-area_20220402171316.png]

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bd45879f-9f72-478e-9cf6-0b5a1bad0b55n%40googlegroups.com.


django html error

2022-04-02 Thread 5021-Chandra Prakash.S
i am new to django, there is no error in my project but my html page is not 
loading ,its just appearing white blank screen when i run the server.I had 
checked settings.py file and edited the templates setting but then too my 
html file isn't loading.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e2efbfba-b612-48d8-9012-e277cb21d7e9n%40googlegroups.com.


Re: django.db.utils.OperationalError: index row requires 45344 bytes, maximum size is 8191

2022-04-02 Thread Antonis Christofides
Sorry, which model is causing the problem? Which is the model that started 
giving you errors when you added the Meta?


Antonis Christofides
+30-6979924665 (mobile)



On 02/04/2022 15.00, Sunday Ajayi wrote:

Hi Antonis below is my model definition:


from django.db import models
from authentication.models import User,Business
import cloudinary
from cloudinary.models import CloudinaryField
from django.core.paginator import 
Paginator,EmptyPage,PageNotAnInteger,InvalidPage
from rest_framework.pagination import PageNumberPagination
from django.contrib.postgres.fields import ArrayField
# Create your models here.
DATA_PER_PAGE =10
class Category(models.Model):
TYPE = (
('custom','custom'),
('non-custom','non-custom')
)
STATE = (
('untrained','Untrained'),
('in-progress','Training in Progress'),
('more-training','More Training Needed'),
('trained','Trained')
)
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=255, blank=True,null=True)
slug = models.CharField(max_length=20,null=True,blank=True)
category_type = 
models.CharField(max_length=20,choices=TYPE,default='non-custom',null=True,blank=True)

description = models.TextField(blank=True,null=True)
business = models.ForeignKey(Business, 
on_delete=models.DO_NOTHING,null=True,blank=True)
image = 
models.ImageField(upload_to='category',null=True,blank=True,default='/media/category/unnamed-5.png')

extracted_data = models.JSONField(blank=True,null=True)
state = 
models.CharField(max_length=20,choices=STATE,default='untrained',null=True,blank=True)

training_status = models.BooleanField(default=False,null=True,blank=True)
f1_score = models.FloatField(null=True,blank=True)
accuracy = models.FloatField(null=True,blank=True)
progessive_training_file = models.TextField(null=True, blank=True)
created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, 
on_delete=models.DO_NOTHING,null=True,blank=True,related_name='user_cat')

def __str__(self) -> str:
return self.name
class Batch(models.Model):
id = models.AutoField(primary_key=True)
description = models.TextField(blank=True,null=True)
business = models.ForeignKey(Business, 
on_delete=models.DO_NOTHING,null=True,blank=True)
category = models.ForeignKey(Category,on_delete=models.DO_NOTHING, 
null=True,blank=True)

counts = models.BigIntegerField(null=True, blank=True)
created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, 
null=True,blank=True,related_name='user_batch')

def __str__(self) -> str:
return str(self.id)
class Custom_model_extract(models.Model):
id = models.AutoField(primary_key=True)
title = models.CharField(max_length=255, null=True,blank=True)
batch = models.BigIntegerField(null=True,blank=True)
category = models.ForeignKey(Category,on_delete=models.DO_NOTHING, 
null=True,blank=True)

image_extract = models.FileField(upload_to='custom_data',blank=True,null=True)
transcribed_data = models.JSONField(null=True,blank=True)
label_data = models.JSONField(null=True,blank=True)
extracted_json = models.JSONField(blank=True,null=True)
business = models.ForeignKey(Business, 
on_delete=models.DO_NOTHING,null=True,blank=True,related_name='bus_extracted')
created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, 
null=True,blank=True,related_name='user_extracted')

created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self) -> str:
return self.name
class Training_model_data(models.Model):
id = models.AutoField(primary_key=True)
category = models.ForeignKey(Category,on_delete=models.DO_NOTHING, 
null=True,blank=True)

# image_extract = 
models.FileField(upload_to='training_data',blank=True,null=True)
image_extract = models.TextField(blank=True,null=True)
transcribed_data = models.JSONField(null=True,blank=True)
label_data = models.JSONField(null=True,blank=True)
business = models.ForeignKey(Business, 
on_delete=models.DO_NOTHING,null=True,blank=True,related_name='training_bus_extracted')
created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, 
null=True,blank=True,related_name='trainng_user_extracted')

created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self) -> str:
return self.name
class PostManager(models.Manager):
def get_paginated_posts(self, user=None):
if user:
posts = super(PostManager, self).filter()
else:
posts = super(PostManager, self).filter()
return Paginator(posts, DATA_PER_PAGE)
class Epassport(models.Model):
id = models.AutoField(primary_key=True)
fullname = models.CharField(max_length=255, null=True,blank=True)
batch = models.BigIntegerField(null=True,blank

Re: django.db.utils.OperationalError: index row requires 45344 bytes, maximum size is 8191

2022-04-02 Thread Sunday Ajayi
Hi Antonis below is my model definition:



from django.db import models
from authentication.models import User,Business
import cloudinary
from cloudinary.models import CloudinaryField

from django.core.paginator import
Paginator,EmptyPage,PageNotAnInteger,InvalidPage
from rest_framework.pagination import PageNumberPagination

from django.contrib.postgres.fields import ArrayField
# Create your models here.

DATA_PER_PAGE =10

class Category(models.Model):
TYPE = (
('custom','custom'),
('non-custom','non-custom')
)
STATE = (
('untrained','Untrained'),
('in-progress','Training in Progress'),
('more-training','More Training Needed'),
('trained','Trained')

)
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=255, blank=True,null=True)
slug = models.CharField(max_length=20,null=True,blank=True)
category_type = models.CharField(max_length=20,choices=TYPE,default=
'non-custom',null=True,blank=True)
description = models.TextField(blank=True,null=True)
business = models.ForeignKey(Business, on_delete=models.DO_NOTHING,null=True
,blank=True)
image = models.ImageField(upload_to='category',null=True,blank=True,default=
'/media/category/unnamed-5.png')
extracted_data = models.JSONField(blank=True,null=True)
state = models.CharField(max_length=20,choices=STATE,default='untrained',
null=True,blank=True)
training_status = models.BooleanField(default=False,null=True,blank=True)
f1_score = models.FloatField(null=True,blank=True)
accuracy = models.FloatField(null=True,blank=True)
progessive_training_file = models.TextField(null=True, blank=True)
created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING,null=True,
blank=True,related_name='user_cat')

def __str__(self) -> str:
return self.name
class Batch(models.Model):
id = models.AutoField(primary_key=True)
description = models.TextField(blank=True,null=True)
business = models.ForeignKey(Business, on_delete=models.DO_NOTHING,null=True
,blank=True)
category = models.ForeignKey(Category,on_delete=models.DO_NOTHING, null=True
,blank=True)
counts = models.BigIntegerField(null=True, blank=True)
created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, null=True,
blank=True,related_name='user_batch')
def __str__(self) -> str:
return str(self.id)


class Custom_model_extract(models.Model):
id = models.AutoField(primary_key=True)
title = models.CharField(max_length=255, null=True,blank=True)
batch = models.BigIntegerField(null=True,blank=True)
category = models.ForeignKey(Category,on_delete=models.DO_NOTHING, null=True
,blank=True)
image_extract = models.FileField(upload_to='custom_data',blank=True,null=
True)
transcribed_data = models.JSONField(null=True,blank=True)
label_data = models.JSONField(null=True,blank=True)
extracted_json = models.JSONField(blank=True,null=True)
business = models.ForeignKey(Business, on_delete=models.DO_NOTHING,null=True
,blank=True,related_name='bus_extracted')
created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, null=True,
blank=True,related_name='user_extracted')
created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self) -> str:
return self.name


class Training_model_data(models.Model):
id = models.AutoField(primary_key=True)
category = models.ForeignKey(Category,on_delete=models.DO_NOTHING, null=True
,blank=True)
# image_extract =
models.FileField(upload_to='training_data',blank=True,null=True)
image_extract = models.TextField(blank=True,null=True)
transcribed_data = models.JSONField(null=True,blank=True)
label_data = models.JSONField(null=True,blank=True)
business = models.ForeignKey(Business, on_delete=models.DO_NOTHING,null=True
,blank=True,related_name='training_bus_extracted')
created_by = models.ForeignKey(User, on_delete=models.DO_NOTHING, null=True,
blank=True,related_name='trainng_user_extracted')
created_date = models.DateField(auto_now_add=True)
created_time = models.TimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self) -> str:
return self.name
class PostManager(models.Manager):
def get_paginated_posts(self, user=None):
if user:
posts = super(PostManager, self).filter()
else:
posts = super(PostManager, self).filter()
return Paginator(posts, DATA_PER_PAGE)

class Epassport(models.Model):
id = models.AutoField(primary_key=True)
fullname = models.CharField(max_length=255, null=True,blank=True)
batch = models.BigIntegerField(null=True,blank=True)
category = models.ForeignKey(Category,on_delete=models.DO_NOTHING, null=True
,blank=True)
image_extract = models.FileField(upload_to='e_passport_images',blank=True,
null=True)
extracted_json = models.JSO