Q:

custom foreign key values based on constrain

I have a model as:
PRODUCT_EXPIRY MODEL:
product_id = model.IntegerField()
expires_in = model.IntegerField() --days count

And another model as:
PRODUCT:
product_id = model.IntegerField()
expires_in = model.IntegeField(blank=True)  --days count
name = model.CharField()
price = model.FloatField()
...other fields

What I want is, let a store add products, and here expires_in (days count) of product is optional, he can choose to add it manually while adding product or if he doesn't, then the expire in is entered from product_expire model, mapping via product_id.
 BUT consider following cases:

Milk X has 3 days of expiry.
Milk Y has 60 days of expiry.
Cocoa powder has 6 months of expiry date.

When a store enter a product, lets suppose he gets it at least after 10 days from manufacturing date. So the expire_in while adding cocoa powder shall be 60-10 = 50 days i.e. products which has expiry greater than say 30 days. Where as milk van delivers milk daily, so product with expiry less than 30 days will have expiry as same without any change i.e. while adding Milk expires_in for Milk X will be 3 days. How can I do so? Does Product model expired_in has to be a Foreign Key?
Eg: Suppose we know coke expires in 1 month, so if a store forgets to enter expiry date, the automatic expiry date added shall be 20 days. So as later I can notify store if product will soon expire. But for Milk expiry added shall be without any change.
Or do I have to build a custom algorithm for this via overriding the save function of product model?
What I am thinking by now is:

keeping it as IntegerField and adding another field as DateTime,
if date time field is entered, use that, else use the expired_in
field, and overriding the save function.
Handling blank values later via pandas or some custom python script.
But is there an easy way?

A:

as i see the model should look like
class Product(models.Model):
    """
    """
    class Meta:
        verbose_name = _("Procuct")
        verbose_name_plural = _("Products")
    quantity = model.IntegeField() #Imagine ther are 50 packs of coffe that have arrived today
    name = models.CharField(max_length=255, verbose_name=_("name"))
    prise = FloatField()
    expiry_date = models.DateField()
    arrived_at = models.DateField()
    status = 'not_expired'

    def __str__(self):
        return '{name} {expiry_date}'.format(name=self.name, expiry_date=self.expiry_date)

better use Expiry date instead exprites_in because if an employee should type everythin will be more time consuming instead of just typing the expiry date
then if you want to check the products that will expire the next 5 days just 
import date
def checkExpiringProducts(days)
    return Products.objects.filter(status='not_expired',expiry_date__lte=date.today()+datetime.timedelta(days=days)

if you call 
checkExpiringProducts(5)#gives you the products that are expiring next 5 days

you should put status though and check every day if there is  a product with expiry_date today or tommorow to make it's status expired

