Category : instance

I want to load a global menu for any template. The structure of the Query is always the same… class ProductCats(db.Model): def __init__(self, lang=None, catname=None, catid=None, update=False, active=False, create=False, ): self.categories = db.session.query(ProductCats, ProductCatsTranslations) if lang: self.categories = self.categories.filter(ProductCatsTranslations.language_code==lang) if catid: self.categories = self.categories.filter(ProductCatsTranslations.catid==catid) if active: self.categories = self.categories.filter(ProductCats.active==active) self.categories = self.categories.filter(ProductCatsTranslations.catid==ProductCats.catid). order_by(ProductCatsTranslations.sort) self.dicted_by_catid = ..

Read more

is it possible to insert the session value to the foreign key.? here i have 2 models class candidate(models.Model): fname=models.CharField("First name ",max_length=20,default="") lname=models.CharField("Last name ",max_length=20,default="") email=models.EmailField("Email ",max_length=254,primary_key=True) password=models.CharField("Password ",max_length=100,default="") def __str__(self): return self.email #self.fname+" " +self.lname here iam taking the email from above model as a session and trying to put this session value to ..

Read more

I created this simple variation on a dict (similar to the AttrDict module) class AttrDict(dict): def __init__(self, init={}): dict.__init__(self, init) def __setitem__(self, key, value): return super(AttrDict, self).__setitem__(key, value) def __getitem__(self, name): return super(AttrDict, self).__getitem__(name) __getattr__ = __getitem__ __setattr__ = __setitem__ and then it is an attribute of this simple class, receiving a single key/value pair: ..

Read more

I’m trying to learn python with some data-structure. I’m trying to create a binary tree. So I’ve created a node like: class Node(object): def __init__(self,value,left,right): self.value = value self.left = left self.right = right Then I’ve created a tree like: class Tree(object): def __init__(self): self.node = None def insert(self,node,element): if node == None: node = ..

Read more

I have created a database model that saved user-added settings to the database. and I would like to read from these database entries to print reports. I have already read from the forms instances to allow the use to edit the settings like this : Url : path(‘accConnect/setting/<int:setting_pk>’, views.viewSettings, name=’viewSettings’ ), Views: setting = get_object_or_404(SettingsClass, ..

Read more