Re: Updating FK values for Stock Application

2021-06-07 Thread Sharif Mehedi
 Hi Shazia,


On Monday, June 7, 2021, 5:38:38 PM GMT+6, Shazia Nusrat 
 wrote:  
 
 >>> Hi, 


>>> I need to update my orders model with available quantity and literals. My 
>>> Orders are:
You can use GenericForenignKey field for such use case in your Orders Model. 
see the doc: 
https://docs.djangoproject.com/en/3.2/ref/contrib/contenttypes/#generic-relations
>>> class Orders(models.Model):>>>      update_chemical = models.ForeignKey(…..
>>> I just need your help to give me idea that how I can update my orders with 
>>> multiple fields from Stock. For instance if I create >>> a foreignkey I 
>>> will only be able to select one of the "id" in available stocks. I need to 
>>> let the user select or update multiple >>> values in a FK based key. Please 
>>> advise. 
>>> Best Regards,>>> Shazia
Regards,Sharif


-- 
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/ed643b75-005f-484d-a004-a14449c7d372n%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/1716640108.4539959.1623085365728%40mail.yahoo.com.


Re: Updating FK values for Stock Application

2021-06-07 Thread Shazia Nusrat
All I was asking to make FK editable. I can do it in views by making forms 
from "forms.Form" in Django and update models I needed to update.

Just thought that there might be a simpler way where I can choose an option 
from ManyToMany select box and then edit those values. 


On Monday, June 7, 2021 at 5:32:12 PM UTC+5 frds...@gmail.com wrote:

> If you want to have multiple chemicals in a single order then you'll have 
> to use ManyToManyField instead of ForeignKey field.
>
> On Mon, Jun 7, 2021 at 5:08 PM Shazia Nusrat  wrote:
>
>> Hi, 
>> I am developing a stock management application and I am stuck at simple 
>> use case.
>>
>> Following is my model for Stock:
>>
>> class LiquidChemicalML(Stock):
>> supplier_name = models.ManyToManyField(Supplier)
>> quantity_values = (
>> ('Ounces', 'Ounces'),
>> ('Millilitters', 'Millilitters'),
>> ('Pounds', 'Pounds'),
>> ('Liter', 'Liter'),
>> ('Galon', 'Galon'),
>> ('Kilogram', 'Kilogram'),
>> ('Grams', 'Grams')
>> )
>> chemical_name = models.CharField(max_length=200)
>> chemical_quantity = models.IntegerField()
>> unit_of_measurement = models.CharField(max_length=20, 
>> choices=quantity_values)
>> purchase_date = models.DateField()
>> expiry_date = models.DateField()class LiquidChemicalML(Stock):
>> supplier_name = models.ManyToManyField(Supplier)
>> quantity_values = (
>> ('Ounces', 'Ounces'),
>> ('Millilitters', 'Millilitters'),
>> ('Pounds', 'Pounds'),
>> ('Liter', 'Liter'),
>> ('Galon', 'Galon'),
>> ('Kilogram', 'Kilogram'),
>> ('Grams', 'Grams')
>> )
>> chemical_name = models.CharField(max_length=200)
>> chemical_quantity = models.IntegerField()
>> unit_of_measurement = models.CharField(max_length=20, 
>> choices=quantity_values)
>> purchase_date = models.DateField()
>>
>> I need to update my orders model with available quantity and literals. My 
>> Orders are:
>>
>> class Orders(models.Model):
>>  update_chemical = models.ForeignKey(…..
>>
>> I just need your help to give me idea that how I can update my orders 
>> with multiple fields from Stock. For instance if I create a foreignkey I 
>> will only be able to select one of the "id" in available stocks. I need to 
>> let the user select or update multiple values in a FK based key. Please 
>> advise. 
>>
>> Best Regards,
>> Shazia
>>
>> -- 
>> 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/ed643b75-005f-484d-a004-a14449c7d372n%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/d58daa3e-ffaa-46f0-94af-bb81c8d2db3cn%40googlegroups.com.


Re: Updating FK values for Stock Application

2021-06-07 Thread FIRDOUS BHAT
If you want to have multiple chemicals in a single order then you'll have
to use ManyToManyField instead of ForeignKey field.

On Mon, Jun 7, 2021 at 5:08 PM Shazia Nusrat  wrote:

> Hi,
> I am developing a stock management application and I am stuck at simple
> use case.
>
> Following is my model for Stock:
>
> class LiquidChemicalML(Stock):
> supplier_name = models.ManyToManyField(Supplier)
> quantity_values = (
> ('Ounces', 'Ounces'),
> ('Millilitters', 'Millilitters'),
> ('Pounds', 'Pounds'),
> ('Liter', 'Liter'),
> ('Galon', 'Galon'),
> ('Kilogram', 'Kilogram'),
> ('Grams', 'Grams')
> )
> chemical_name = models.CharField(max_length=200)
> chemical_quantity = models.IntegerField()
> unit_of_measurement = models.CharField(max_length=20,
> choices=quantity_values)
> purchase_date = models.DateField()
> expiry_date = models.DateField()class LiquidChemicalML(Stock):
> supplier_name = models.ManyToManyField(Supplier)
> quantity_values = (
> ('Ounces', 'Ounces'),
> ('Millilitters', 'Millilitters'),
> ('Pounds', 'Pounds'),
> ('Liter', 'Liter'),
> ('Galon', 'Galon'),
> ('Kilogram', 'Kilogram'),
> ('Grams', 'Grams')
> )
> chemical_name = models.CharField(max_length=200)
> chemical_quantity = models.IntegerField()
> unit_of_measurement = models.CharField(max_length=20,
> choices=quantity_values)
> purchase_date = models.DateField()
>
> I need to update my orders model with available quantity and literals. My
> Orders are:
>
> class Orders(models.Model):
>  update_chemical = models.ForeignKey(…..
>
> I just need your help to give me idea that how I can update my orders with
> multiple fields from Stock. For instance if I create a foreignkey I will
> only be able to select one of the "id" in available stocks. I need to let
> the user select or update multiple values in a FK based key. Please advise.
>
> Best Regards,
> Shazia
>
> --
> 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/ed643b75-005f-484d-a004-a14449c7d372n%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/CAFB6YJqCreDM6bZaDm4gr9FYnihC9G4tKFz8%3DXPa3Nay%2BLn03Q%40mail.gmail.com.


Updating FK values for Stock Application

2021-06-07 Thread Shazia Nusrat
Hi, 
I am developing a stock management application and I am stuck at simple use 
case.

Following is my model for Stock:

class LiquidChemicalML(Stock):
supplier_name = models.ManyToManyField(Supplier)
quantity_values = (
('Ounces', 'Ounces'),
('Millilitters', 'Millilitters'),
('Pounds', 'Pounds'),
('Liter', 'Liter'),
('Galon', 'Galon'),
('Kilogram', 'Kilogram'),
('Grams', 'Grams')
)
chemical_name = models.CharField(max_length=200)
chemical_quantity = models.IntegerField()
unit_of_measurement = models.CharField(max_length=20, 
choices=quantity_values)
purchase_date = models.DateField()
expiry_date = models.DateField()class LiquidChemicalML(Stock):
supplier_name = models.ManyToManyField(Supplier)
quantity_values = (
('Ounces', 'Ounces'),
('Millilitters', 'Millilitters'),
('Pounds', 'Pounds'),
('Liter', 'Liter'),
('Galon', 'Galon'),
('Kilogram', 'Kilogram'),
('Grams', 'Grams')
)
chemical_name = models.CharField(max_length=200)
chemical_quantity = models.IntegerField()
unit_of_measurement = models.CharField(max_length=20, 
choices=quantity_values)
purchase_date = models.DateField()

I need to update my orders model with available quantity and literals. My 
Orders are:

class Orders(models.Model):
 update_chemical = models.ForeignKey(…..

I just need your help to give me idea that how I can update my orders with 
multiple fields from Stock. For instance if I create a foreignkey I will 
only be able to select one of the "id" in available stocks. I need to let 
the user select or update multiple values in a FK based key. Please advise. 

Best Regards,
Shazia

-- 
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/ed643b75-005f-484d-a004-a14449c7d372n%40googlegroups.com.