Re: Negative Stock Prevention

2022-08-31 Thread tech george
I managed to remove the error,

I had a negative stock in my DB.

Thanks a lot for the help.

On that note, I was also trying to get the dispensed from stock

I was trying to do this but I don't think it can work since there is
already a foreign key at Dispense model fetching drug_id from stock.

What's the best way out?

@property
def dispensed(self):
return (self.quantity - self.dispense.quantity)




On Thu, Sep 1, 2022 at 6:09 AM Ammar Mohammed  wrote:

> I don't think you need that constraint after using the
> PositiveIntegerField .
>
>
> On Thu, 1 Sep 2022, 02:45 Ryan Nowakowski,  wrote:
>
>> I don't see any error. Did you forget to post it?
>>
>> On August 31, 2022 5:57:32 AM CDT, tech george 
>> wrote:
>>>
>>> Hello,
>>>
>>> Sorry for the late reply.
>>>
>>> I changed the models as below and added checkConstraint , But when I
>>> migrate I get the below error.
>>>
>>> What am I still doing wrong?
>>>
>>> class Stock(models.Model):
>>> quantity = models.PositiveIntegerField(default='0', blank=True,
>>> null=True)
>>> reorder_level = models.PositiveIntegerField(default='0', blank=True,
>>> null=True)
>>>
>>> class Meta:
>>> CheckConstraint(check=Q(quantity__gt=0), name='quantity')
>>>
>>>
>>>
>>> On Tue, Aug 30, 2022 at 6:09 PM Thomas Couch  wrote:
>>>
 I don't see where you define the quantity variable, should that be
 instance.quantity? Also, presumably you want to check if quantity is
 greater than or equal to qu rather than 0.
 Try changing `if quantity > 0` to `if instance.quantity >= qu`


 On Tuesday, August 30, 2022 at 3:44:51 PM UTC+1 Ryan Nowakowski wrote:

> On Mon, Aug 29, 2022 at 05:18:39PM +0300, tech george wrote:
> > Please help crack the below code, I want to prevent negative stock,
> and if
> > the stock is == 0, deduct it from reorder_level instead.
> > Currently, the stock goes negative.
> >
> > models.py
> >
> > class Stock(models.Model):
> > quantity = models.IntegerField(default='0', blank=True, null=True)
> > reorder_level = models.IntegerField(default='0', blank=True,
> null=True)
> >
> > class Dispense(models.Model):
> > 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)
>
> Maybe change quantity and reorder_level to PositiveIntegerField?
>
 --
 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/9ef2d260-7c1a-4ff1-95ca-c13ded5f9f7bn%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/DDF83E16-47C4-4E38-90DE-6CDAE28268DB%40fattuba.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/CAHs1H7uN4xCF%2B7AKqxSufatWiUN_n9cw4uBALo-ENFOfirp_hg%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/CADYG20EXeqBXyAQsG0zpk6HXxcKixhjvy_R9z1QiY6%3Da5cAvFg%40mail.gmail.com.


Re: Deploy Django Project in AAPanel

2022-08-31 Thread 'Kasper Laudrup' via Django users

On 01/09/2022 02.10, Javier L. Camacaro wrote:

Does someone how to deploy a Django Project in AAPanel?



https://forum.aapanel.com/d/13338-python-manager-deploy-djangoblog

Kind regards,

Kasper Laudrup

--
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/f916369f-b05d-0c33-d094-49dc401157e1%40stacktrace.dk.


OpenPGP_0xE5D9CAC64AAA55EB.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Re: Negative Stock Prevention

2022-08-31 Thread tech george
Hello,

Sorry the error is:

django.db.utils.IntegrityError: CHECK constraint failed: quantity



On Thu, Sep 1, 2022 at 3:45 AM Ryan Nowakowski  wrote:

> I don't see any error. Did you forget to post it?
>
> On August 31, 2022 5:57:32 AM CDT, tech george 
> wrote:
>>
>> Hello,
>>
>> Sorry for the late reply.
>>
>> I changed the models as below and added checkConstraint , But when I
>> migrate I get the below error.
>>
>> What am I still doing wrong?
>>
>> class Stock(models.Model):
>> quantity = models.PositiveIntegerField(default='0', blank=True,
>> null=True)
>> reorder_level = models.PositiveIntegerField(default='0', blank=True,
>> null=True)
>>
>> class Meta:
>> CheckConstraint(check=Q(quantity__gt=0), name='quantity')
>>
>>
>>
>> On Tue, Aug 30, 2022 at 6:09 PM Thomas Couch  wrote:
>>
>>> I don't see where you define the quantity variable, should that be
>>> instance.quantity? Also, presumably you want to check if quantity is
>>> greater than or equal to qu rather than 0.
>>> Try changing `if quantity > 0` to `if instance.quantity >= qu`
>>>
>>>
>>> On Tuesday, August 30, 2022 at 3:44:51 PM UTC+1 Ryan Nowakowski wrote:
>>>
 On Mon, Aug 29, 2022 at 05:18:39PM +0300, tech george wrote:
 > Please help crack the below code, I want to prevent negative stock,
 and if
 > the stock is == 0, deduct it from reorder_level instead.
 > Currently, the stock goes negative.
 >
 > models.py
 >
 > class Stock(models.Model):
 > quantity = models.IntegerField(default='0', blank=True, null=True)
 > reorder_level = models.IntegerField(default='0', blank=True,
 null=True)
 >
 > class Dispense(models.Model):
 > 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)

 Maybe change quantity and reorder_level to PositiveIntegerField?

>>> --
>>> 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/9ef2d260-7c1a-4ff1-95ca-c13ded5f9f7bn%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/DDF83E16-47C4-4E38-90DE-6CDAE28268DB%40fattuba.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/CADYG20H6Yv_Y0vkgqVzOU90emRP%3DnvUw7vRrM--HGNbb0zZCAA%40mail.gmail.com.


Re: Negative Stock Prevention

2022-08-31 Thread Ammar Mohammed
I don't think you need that constraint after using the PositiveIntegerField
.


On Thu, 1 Sep 2022, 02:45 Ryan Nowakowski,  wrote:

> I don't see any error. Did you forget to post it?
>
> On August 31, 2022 5:57:32 AM CDT, tech george 
> wrote:
>>
>> Hello,
>>
>> Sorry for the late reply.
>>
>> I changed the models as below and added checkConstraint , But when I
>> migrate I get the below error.
>>
>> What am I still doing wrong?
>>
>> class Stock(models.Model):
>> quantity = models.PositiveIntegerField(default='0', blank=True,
>> null=True)
>> reorder_level = models.PositiveIntegerField(default='0', blank=True,
>> null=True)
>>
>> class Meta:
>> CheckConstraint(check=Q(quantity__gt=0), name='quantity')
>>
>>
>>
>> On Tue, Aug 30, 2022 at 6:09 PM Thomas Couch  wrote:
>>
>>> I don't see where you define the quantity variable, should that be
>>> instance.quantity? Also, presumably you want to check if quantity is
>>> greater than or equal to qu rather than 0.
>>> Try changing `if quantity > 0` to `if instance.quantity >= qu`
>>>
>>>
>>> On Tuesday, August 30, 2022 at 3:44:51 PM UTC+1 Ryan Nowakowski wrote:
>>>
 On Mon, Aug 29, 2022 at 05:18:39PM +0300, tech george wrote:
 > Please help crack the below code, I want to prevent negative stock,
 and if
 > the stock is == 0, deduct it from reorder_level instead.
 > Currently, the stock goes negative.
 >
 > models.py
 >
 > class Stock(models.Model):
 > quantity = models.IntegerField(default='0', blank=True, null=True)
 > reorder_level = models.IntegerField(default='0', blank=True,
 null=True)
 >
 > class Dispense(models.Model):
 > 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)

 Maybe change quantity and reorder_level to PositiveIntegerField?

>>> --
>>> 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/9ef2d260-7c1a-4ff1-95ca-c13ded5f9f7bn%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/DDF83E16-47C4-4E38-90DE-6CDAE28268DB%40fattuba.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/CAHs1H7uN4xCF%2B7AKqxSufatWiUN_n9cw4uBALo-ENFOfirp_hg%40mail.gmail.com.


Re: Negative Stock Prevention

2022-08-31 Thread Ryan Nowakowski
I don't see any error. Did you forget to post it?

On August 31, 2022 5:57:32 AM CDT, tech george  wrote:
>Hello,
>
>Sorry for the late reply.
>
>I changed the models as below and added checkConstraint , But when I
>migrate I get the below error.
>
>What am I still doing wrong?
>
>class Stock(models.Model):
>quantity = models.PositiveIntegerField(default='0', blank=True,
>null=True)
>reorder_level = models.PositiveIntegerField(default='0', blank=True,
>null=True)
>
>class Meta:
>CheckConstraint(check=Q(quantity__gt=0), name='quantity')
>
>
>
>On Tue, Aug 30, 2022 at 6:09 PM Thomas Couch  wrote:
>
>> I don't see where you define the quantity variable, should that be
>> instance.quantity? Also, presumably you want to check if quantity is
>> greater than or equal to qu rather than 0.
>> Try changing `if quantity > 0` to `if instance.quantity >= qu`
>>
>>
>> On Tuesday, August 30, 2022 at 3:44:51 PM UTC+1 Ryan Nowakowski wrote:
>>
>>> On Mon, Aug 29, 2022 at 05:18:39PM +0300, tech george wrote:
>>> > Please help crack the below code, I want to prevent negative stock, and
>>> if
>>> > the stock is == 0, deduct it from reorder_level instead.
>>> > Currently, the stock goes negative.
>>> >
>>> > models.py
>>> >
>>> > class Stock(models.Model):
>>> > quantity = models.IntegerField(default='0', blank=True, null=True)
>>> > reorder_level = models.IntegerField(default='0', blank=True, null=True)
>>> >
>>> > class Dispense(models.Model):
>>> > 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)
>>>
>>> Maybe change quantity and reorder_level to PositiveIntegerField?
>>>
>> --
>> 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/9ef2d260-7c1a-4ff1-95ca-c13ded5f9f7bn%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/CADYG20F0occUAajR%3DSseRtiW%2Bzjh4THmgN6FEFbFsGcpsmMLZg%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/DDF83E16-47C4-4E38-90DE-6CDAE28268DB%40fattuba.com.


Deploy Django Project in AAPanel

2022-08-31 Thread Javier L. Camacaro
 

Does someone how to deploy a Django Project in AAPanel?

I tried Python Maganer 2.0 but impossible for me!
I get this error: 

Sorry, something went wrong: Traceback (most recent call last): File 
"class/flask_sockets.py", line 30, in *call* handler, values = 
adapter.match() File 
"/www/server/panel/pyenv/lib/python3.7/site-packages/werkzeug/routing.py", 
line 1945, in match raise NotFound() werkzeug.exceptions.NotFound: 404 Not 
Found: The requested URL was not found on the server. If you entered the 
URL manually please check your spelling and try again. 

...and many others after that

Please help 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/66e880c0-9561-41bb-93bb-e08475f9eb19n%40googlegroups.com.


Re: Bug with Watchman on Windows

2022-08-31 Thread 'Kasper Laudrup' via Django users

On 31/08/2022 18.52, David V wrote:

Hello All,

Apologies if this is the wrong place to submit this. I couldn't find 
clear enough documentation on where to do this, so I guess I ended up here.




Maybe open an issue on the issue tracker on github?

https://github.com/facebook/watchman

Kind regards,

Kasper Laudrup

--
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/4a0fec42-ee50-d9d5-5d60-913c607e551c%40stacktrace.dk.


OpenPGP_0xE5D9CAC64AAA55EB.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


Bug with Watchman on Windows

2022-08-31 Thread David V
Hello All,

Apologies if this is the wrong place to submit this. I couldn't find clear 
enough documentation on where to do this, so I guess I ended up here.

I installed pywatchman along with FB's watchman expecting StatReloader to 
change to WatchmnaReloader. Sadly, I was mistaken.

Python version: 3.9
Django version: 4.1
pywatchman version: 1.4.1
OS: Windows 11
PyCharm version: 2022.2.1
conda environment

Steps to reproduce:
Install Django
Install pywatchman
Install Watchman
Confirm Watchman is running
Start a django project
run: python manage.py runserver

I tracked the issue down to django.utils.autoreload.py. It seems that on 
client.capabilityCheck(), optional is a keyword argument set equal to None 
(optional=None), which is a problem because later when pywatchman call 
capabilities.synthesize() in pywatchman.capabilityCheck() (line 1079), it 
doesn't work because a for loop gets called on optional that was passed in. 
In Python for x in None: does not work. Could we get a kwarg added optional 
= [ ] in the function call for result = cliient.capabilityCheck() on line 
628 in autoreload.py? I was able to sidestep the issue by inserting version 
= (4, 9) above line 627 where the try:...except:... is initialized in 
check_availability and then commenting out lines 627–632—try:...version = 
get_vers

I know that then it won't provide the correct Watchman version, but it 
would be nice if it worked out of the box like it is supposed to.

Please let me know what further steps I should take to make sure that 
watchman works out of the box like it is supposed to.

Thanks,

David V.

-- 
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/8dad35c6-0442-4cdb-837b-5629dc89ffdan%40googlegroups.com.


Re: I want to fetch the value of radio field for updation but it only doesn't fetch even i use condition and value does comes but doesn't checked

2022-08-31 Thread Godswill King Trace
I have this problem too

On Wed, Aug 24, 2022, 5:06 PM Mihir Patel  wrote:

> i dont have much idea but try to do with True Or False value bcz maybe it
> returns boolean value.
>
> On Mon, Aug 22, 2022 at 12:27 PM Abhinandan K 
> wrote:
>
>> Email
>> 
>> {% with val_gen=datas.gender%}
>> {{val_gen}}
>> gender:
>>
>> > checked{% endif %} >Male
>> > %} checked{% endif %}>Female
>> 
>> {% endwith %}
>> 
>>
>> --
>> 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/CAA6_Mp44RQjMeWfVW82vvT2-GLrv5Jpu2nb_6edWON_3sgXQwQ%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/CAC10kRG9fXHxO3WPaWftOWEH6jXoV%3D6DNEoV2UyoQNah53NaDA%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/CAEfX8_3JyvBtt%3DHPD%3DEDx-SQ5LEQBkYJS%2Bj37YR8eqkT7igLKA%40mail.gmail.com.


Re: User authentication with simple-jwt drf

2022-08-31 Thread Mobina J
hii 

import pandas as pd
from django.contrib import messages
from django.core.mail import EmailMessage
from django.shortcuts import render
from django.template.loader import render_to_string
from app_1.form import NotificationForm


def email_generic_template(request):
form = NotificationForm(request.POST)
if form.is_valid():
csv_file = request.FILES['file']
data = pd.read_csv(csv_file)
subj = request.POST.get('subject')
msg = request.POST.get('message')
BCC = request.POST.get('bcc_email')
CC = request.POST.get('cc_email')
answer = request.POST.get('selected_option')
demo = list()
try:
for k, r in data.iterrows():
value = r.to_dict()
recipient = value["email_id"]
Subject = subj.format(**value)
Body_of_message = msg.format(**value)
bcc = BCC.format(**value)
cc = CC.format(**value)
FROM_EMAIL = "exam...@gmail.com"
html_template = render_to_string('mail_template.html', {'content': 
Body_of_message})
email1 = EmailMessage(
Subject,
html_template,
FROM_EMAIL,
[recipient],
bcc=[bcc],
cc=[cc]
)
email1.content_subtype = 'html'
sent = email1.send()
value['sent'] = sent
demo.append(value)
if sent == 1:
sent = 'success'
print(sent)
else:
sent = 'Fail'
print(sent)
if answer == 'sample_mail':
break
context = {
'form': form,
'value': demo,
}
return render(request, 'index.html', context)
except Exception as e:
messages.error(request, e)
context = {
'form': form,
'value': demo
}
return render(request, 'index.html', context)

else:
context = {'form': form}
return render(request, 'index.html', context)
  



this is my code...I want to show failed mail to the template...I am new to 
Django I did not know how to do it. anyone  help me
On Wednesday, August 24, 2022 at 7:24:23 PM UTC+5:30 dashlaksh...@gmail.com 
wrote:

> Hello everyone,
> I want to create a user authentication app using ReactJS and django. But 
> facing problems in authenticating with the jsonwebtokens in ReactJS. Can 
> anybody provide correct guide of implementing DjangoRestFramework 
> simple-jwt and ReactJS jet ?
>

-- 



_Disclaimer: _© 2022 VVDN Technologies Pvt. Ltd. This e-mail contains 
PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the 
addressee(s). If you are not the intended recipient, please notify the 
sender by e-mail and delete the original message. Further, you are not to 
copy, disclose, or distribute this e-mail or its contents to any other 
person and any such actions are unlawful._
_
_
_
__

-- 
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/87302199-bf5f-4aae-bcaf-ab6ab2401c0fn%40googlegroups.com.


Re: Negative Stock Prevention

2022-08-31 Thread tech george
Hello,

Sorry for the late reply.

I changed the models as below and added checkConstraint , But when I
migrate I get the below error.

What am I still doing wrong?

class Stock(models.Model):
quantity = models.PositiveIntegerField(default='0', blank=True,
null=True)
reorder_level = models.PositiveIntegerField(default='0', blank=True,
null=True)

class Meta:
CheckConstraint(check=Q(quantity__gt=0), name='quantity')



On Tue, Aug 30, 2022 at 6:09 PM Thomas Couch  wrote:

> I don't see where you define the quantity variable, should that be
> instance.quantity? Also, presumably you want to check if quantity is
> greater than or equal to qu rather than 0.
> Try changing `if quantity > 0` to `if instance.quantity >= qu`
>
>
> On Tuesday, August 30, 2022 at 3:44:51 PM UTC+1 Ryan Nowakowski wrote:
>
>> On Mon, Aug 29, 2022 at 05:18:39PM +0300, tech george wrote:
>> > Please help crack the below code, I want to prevent negative stock, and
>> if
>> > the stock is == 0, deduct it from reorder_level instead.
>> > Currently, the stock goes negative.
>> >
>> > models.py
>> >
>> > class Stock(models.Model):
>> > quantity = models.IntegerField(default='0', blank=True, null=True)
>> > reorder_level = models.IntegerField(default='0', blank=True, null=True)
>> >
>> > class Dispense(models.Model):
>> > 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)
>>
>> Maybe change quantity and reorder_level to PositiveIntegerField?
>>
> --
> 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/9ef2d260-7c1a-4ff1-95ca-c13ded5f9f7bn%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/CADYG20F0occUAajR%3DSseRtiW%2Bzjh4THmgN6FEFbFsGcpsmMLZg%40mail.gmail.com.


enumerate login in django

2022-08-31 Thread Dilja E G
how to create a function to login with user nam e. if user name and 
password is already exist, but want to login with user for super user.

-- 
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/92a4fb37-819b-4478-b501-d66bad01546dn%40googlegroups.com.