Models Culculations

2022-08-03 Thread tech george
Hello,

Please help with the below, I am trying to get dispense_quantity from
Dispense Model and subtract it from the quantity on Stock Model.

Then after that get something like this;

@property
def closing_stock(self):
  return (self.quantity - self. quantity_issued  )

class Stock(models.Model):
unit_price = models.DecimalField(max_digits=10, decimal_places=2,
default='0', blank=True, null=True)
quantity = models.IntegerField(default='0', blank=True, null=True)
total_price = models.DecimalField(max_digits=10, decimal_places=2,
default=1)
total_stock = models.IntegerField(default='0', blank=True, null=True)
receive_quantity = models.IntegerField(default='0', blank=True, null=True)
reorder_level = models.IntegerField(default='0', blank=True, null=True)
reorder_price = models.DecimalField(max_digits=10,
decimal_places=2, default='0', blank=True, null=True)

def __str__(self):
return str(self.drug_name)

@property
def total_price(self):
return (self.quantity + self.reorder_level) * self.unit_price

@property
def total_stock(self):
return (self.quantity + self.reorder_level)

@property
def reorder_stock(self):
return (self.reorder_level * self.reorder_price)

class Dispense(models.Model):
nurse = models.ForeignKey(Pharmacist, on_delete=models.CASCADE, null=True)
patient_id = models.ForeignKey(Patients,
on_delete=models.DO_NOTHING, null=True)
drug_id = models.ForeignKey(Stock, on_delete=models.SET_NULL,
null=True, blank=False)
dispense_quantity = models.PositiveIntegerField(default='1',
blank=False, null=True)
taken = models.CharField(max_length=300, null=True, blank=True)

-- 
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/CADYG20E1AotncUkEVrooR4RqHr24gPK_oCd8S4iqre2HOfdABg%40mail.gmail.com.


Re: Combine Existing React App with Existing Django App

2022-08-03 Thread Abdul Qoyyuum
Yes it can be done. Django to provide API endpoints. React app to connect
to those API endpoints.

Abdul Qoyyuum Bin Haji Abdul Kadir
System Engineer at Card Access Services
HP: +673 720 8043

On Thu, Aug 4, 2022, 8:38 AM Lightning Bit <
thelegendofearthretu...@gmail.com> wrote:

> Is it possible to combine an existing React App with an existing Django
> App?
>
> --
> 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/7e99a963-08bf-4d76-b80e-2c42576b0ca1n%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/CAA3DN%3DU_RF%2B1EwcE7FHAndTr5k%3DBR4UStxQYtDSE9h2krpiJgg%40mail.gmail.com.


Combine Existing React App with Existing Django App

2022-08-03 Thread Lightning Bit
Is it possible to combine an existing React App with an existing Django App?

-- 
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/7e99a963-08bf-4d76-b80e-2c42576b0ca1n%40googlegroups.com.


Re: Potential admin bug

2022-08-03 Thread Adebileje Nurudeen
I'll get back to you

On Wed, Aug 3, 2022, 8:37 PM Ross Meredith  wrote:

> It's more likely a set up problem than a bug I'd have thought.
>
> If it helps here is the relevant code -
> https://github.com/django/django/blob/main/django/contrib/admin/options.py#L132
> .
>
> def response_add is the method which determines what the response to use
> after a successful addition.
>
> On Wed, Aug 3, 2022 at 7:09 PM Fab  wrote:
>
>> Hey,
>>
>> In the admin when clicking "add model +" I fill out the fields to create
>> my item then when I click "Save and add another" or "Save and continue
>> editing" it redirects back to the model list view even though the item was
>> added successfully. If I click back on to the item to edit it the buttons
>> work how they should.
>>
>> I'm not sure if this is a bug with the admin. I've tried it on 2 projects
>> now. I'm using Django 4.1.
>>
>> I uploaded a sample project so you can quickly see if the issue happens
>> for you too.
>>
>> https://github.com/fabtjar/django_admin_issue
>>
>> Cheers,
>>
>> Fab
>>
>> --
>> 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/eb9cf313-a1c7-45b6-a254-f8f8bb4d3fddn%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/CAA1Tdz1T_C8AchfNNOCTv3CRCJFZAjNhHPyp2cvE76_OoZ_9NQ%40mail.gmail.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/CAOfwBVhSK0RKECbKiTVya-%3DnjKqChFT%2BSDPBfFYRzp-74cnF0Q%40mail.gmail.com.


Re: Potential admin bug

2022-08-03 Thread Adebileje Nurudeen
Okay... So what exactly do you need on it?
So I can just fix it

On Wed, Aug 3, 2022 at 7:09 PM Fab  wrote:

> Hey,
>
> In the admin when clicking "add model +" I fill out the fields to create
> my item then when I click "Save and add another" or "Save and continue
> editing" it redirects back to the model list view even though the item was
> added successfully. If I click back on to the item to edit it the buttons
> work how they should.
>
> I'm not sure if this is a bug with the admin. I've tried it on 2 projects
> now. I'm using Django 4.1.
>
> I uploaded a sample project so you can quickly see if the issue happens
> for you too.
>
> https://github.com/fabtjar/django_admin_issue
>
> Cheers,
>
> Fab
>
> --
> 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/eb9cf313-a1c7-45b6-a254-f8f8bb4d3fddn%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/CAOfwBVgPu%3DQCN_7unMaQmkUaz_GjP-hi1%2Bf9LiSuE1k4rkdJjA%40mail.gmail.com.


Erro em uma consulta Sqlite3

2022-08-03 Thread Alvaro Teixeira Silva
Bom dia amigos, estou desenvolvendo um blog e me deparei com um erro em uma 
consulta, vou mandar o trecho do codigo onde esta o erro:

def get_queryset(self):
qs = super().get_queryset()
qs = qs.order_by('-id')
qs = qs.annotade(
numero_comentarios=Count(
Case(
When(Comentario__publicado_comentario=True, then=1)
)
)
)

return qs

Esse e o erro no terminal:

AttributeError: 'QuerySet' object has no attribute 'annotade'

-- 
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/898a542b-72e5-41d2-8ce3-b12d704972cen%40googlegroups.com.


Re: Potential admin bug

2022-08-03 Thread Ross Meredith
It's more likely a set up problem than a bug I'd have thought.

If it helps here is the relevant code -
https://github.com/django/django/blob/main/django/contrib/admin/options.py#L132
.

def response_add is the method which determines what the response to use
after a successful addition.

On Wed, Aug 3, 2022 at 7:09 PM Fab  wrote:

> Hey,
>
> In the admin when clicking "add model +" I fill out the fields to create
> my item then when I click "Save and add another" or "Save and continue
> editing" it redirects back to the model list view even though the item was
> added successfully. If I click back on to the item to edit it the buttons
> work how they should.
>
> I'm not sure if this is a bug with the admin. I've tried it on 2 projects
> now. I'm using Django 4.1.
>
> I uploaded a sample project so you can quickly see if the issue happens
> for you too.
>
> https://github.com/fabtjar/django_admin_issue
>
> Cheers,
>
> Fab
>
> --
> 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/eb9cf313-a1c7-45b6-a254-f8f8bb4d3fddn%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/CAA1Tdz1T_C8AchfNNOCTv3CRCJFZAjNhHPyp2cvE76_OoZ_9NQ%40mail.gmail.com.


Potential admin bug

2022-08-03 Thread Fab
Hey,

In the admin when clicking "add model +" I fill out the fields to create my 
item then when I click "Save and add another" or "Save and continue 
editing" it redirects back to the model list view even though the item was 
added successfully. If I click back on to the item to edit it the buttons 
work how they should.

I'm not sure if this is a bug with the admin. I've tried it on 2 projects 
now. I'm using Django 4.1.

I uploaded a sample project so you can quickly see if the issue happens for 
you too.

https://github.com/fabtjar/django_admin_issue

Cheers,

Fab

-- 
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/eb9cf313-a1c7-45b6-a254-f8f8bb4d3fddn%40googlegroups.com.


Django + uvicorn poor performance

2022-08-03 Thread Marcin Szpulak


I'm testing Django asgi performance using two very simple views. I'm 
running gunicorn and uvicorn in such a manner:
 1.  gunicorn core.wsgi --workers=1 --threads=1 --access-logfile=- 
core.wsgi:application uvicorn --workers 1 core.asgi:application
2. uvicorn --workers 1 core.asgi:application

View is really simple :
def simple_sync_view(request): 
  usernames = "Hello World" 
  return JsonResponse({'message': usernames})

Project has no middlewares enabled. When testing using : wrk -t10 -c100 
-d10s http://127.0.0.1:8000/test/sync/ synchronous server is always several 
times faster.

So I wonder, is the Django in asgi mode so slow or what ?

-- 
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/44ac71a4-7d6e-481c-a495-e79c8a5d665dn%40googlegroups.com.


Re: Generating Calendar files for iPhone and Android with Pthon3/django

2022-08-03 Thread lone...@gmail.com

well well well.  Look what I found.  https://ical.marudot.com/  I played 
around with the site a little bit and it generated what I was looking for.  
I was looking for a data structure for the Reminder feature of an Event 
object.  What I am doing in my own code is just one long string with 
variables in it.
On Wednesday, August 3, 2022 at 5:02:19 AM UTC-4 christian...@gmail.com 
wrote:

> icalendar is tried and tested and feature complete. 
> OTOH if you want just to serve the iCal files from Google or Apple you 
> don't even need to parse then, just pass them on?
>
> On Tue, 2 Aug 2022 at 15:48, lone...@gmail.com  wrote:
>
>> I found: https://pypi.org/project/icalendar/.  Are there any others out 
>> there?
>>
>> On Tuesday, August 2, 2022 at 10:41:44 AM UTC-4 Ryan Nowakowski wrote:
>>
>>> The standard is called iCal. There are a few different python libraries 
>>> to choose from.
>>>
>>>
>>> On August 1, 2022 2:51:34 PM CDT, "lone...@gmail.com"  
>>> wrote:

 Hello all,

  I want to generate calendar files for both Android and iPhone.  I 
 do not want to connect to the Google or Apple APIs to do this.  I just 
 want 
 static files that are downloaded from my webapp to the mobile device.  How 
 and can this be done?

 Thank you.

 -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/fab30b9f-5afd-459e-9186-f798baedefe5n%40googlegroups.com
>>  
>> 
>> .
>>
>
>
> -- 
> Best Regards,
>
> Christian Ledermann
>
> Galway, IE
> Mobile : +353 (0) 899748838
>
> https://www.linkedin.com/in/christianledermann
> https://github.com/cleder/
>
>
> <*)))>{
>
> If you save the living environment, the biodiversity that we have left,
> you will also automatically save the physical environment, too. But If
> you only save the physical environment, you will ultimately lose both.
>
> 1) Don’t drive species to extinction
>
> 2) Don’t destroy a habitat that species rely on.
>
> 3) Don’t change the climate in ways that will result in the above.
>
> }<(((*>
>

-- 
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/82264155-a7ec-49f2-a752-ac91c826809cn%40googlegroups.com.


Django 4.1 released

2022-08-03 Thread Carlton Gibson
Details are available on the Django project weblog:

https://www.djangoproject.com/weblog/2022/aug/03/django-41-released/

-- 
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/CAJwKpyR3GRReA1qdshq-eNERRTQUHMHznCiLeBntVNoLZ6_kiQ%40mail.gmail.com.


Re: Generating Calendar files for iPhone and Android with Pthon3/django

2022-08-03 Thread Christian Ledermann
icalendar is tried and tested and feature complete.
OTOH if you want just to serve the iCal files from Google or Apple you
don't even need to parse then, just pass them on?

On Tue, 2 Aug 2022 at 15:48, lone...@gmail.com  wrote:

> I found: https://pypi.org/project/icalendar/.  Are there any others out
> there?
>
> On Tuesday, August 2, 2022 at 10:41:44 AM UTC-4 Ryan Nowakowski wrote:
>
>> The standard is called iCal. There are a few different python libraries
>> to choose from.
>>
>>
>> On August 1, 2022 2:51:34 PM CDT, "lone...@gmail.com" 
>> wrote:
>>>
>>> Hello all,
>>>
>>>  I want to generate calendar files for both Android and iPhone.  I
>>> do not want to connect to the Google or Apple APIs to do this.  I just want
>>> static files that are downloaded from my webapp to the mobile device.  How
>>> and can this be done?
>>>
>>> Thank you.
>>>
>>> --
> 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/fab30b9f-5afd-459e-9186-f798baedefe5n%40googlegroups.com
> 
> .
>


-- 
Best Regards,

Christian Ledermann

Galway, IE
Mobile : +353 (0) 899748838

https://www.linkedin.com/in/christianledermann
https://github.com/cleder/


<*)))>{

If you save the living environment, the biodiversity that we have left,
you will also automatically save the physical environment, too. But If
you only save the physical environment, you will ultimately lose both.

1) Don’t drive species to extinction

2) Don’t destroy a habitat that species rely on.

3) Don’t change the climate in ways that will result in the above.

}<(((*>

-- 
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/CABCjzWoiEzdFzg2YRtiW4vz1imGhxJ_ejsz-2Li0AupwCFzT-Q%40mail.gmail.com.


Django security releases issued: 4.0.7 and 3.2.15.

2022-08-03 Thread Carlton Gibson
Details are available on the Django project weblog:

https://www.djangoproject.com/weblog/2022/aug/03/security-releases/

-- 
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/CAJwKpyRZNynRNTqRnE7HCUpNk0Yh1DRg8UUyDZ%2BzFc0pzpcg9g%40mail.gmail.com.