python - Django - filtering in views -
I am working on a basic application and I am stuck in displaying some information. Please see:
Model:
class companies (models.model): name = models.CharField () address = models.CharField () def __unicode __ (self) ): Return itself Name class payments (models.Model): Company = Model Fairanyki (companies) year = Model. Kharifild (option = YEAR) month = model. Kharefild (option = month) date = model.deidfeld (auto_now_add = true) I would like a scene in which only to show companies that do not pay a monthly fee.
So I started this way:
def check (request): i = datetime.datetime.now () an_c = i.strftime ('% Y' ) Comp = Companies.objects.all () pay1 = payments.objects.filter (a = an_c, month = '01 ') But in the template I do not know how "comp" Filter the list. I want to display the template from "Comp" in all the records, except for those who can find ID / PK in "pay1.company"
You will not do this in the template. Do the whole thing in the scene:
plus1 = payment.Object FILTERS (a = an_c, month = '01 ') comp = Companies. Benzax.Xanday (payment_in = pay1) (style note: Django model class is usually kept in singular Is not plural.)
Comments
Post a Comment