Skip to content
Advertisement

Tag: django-models

django custom function for filter query

I’ve a field in my model called, test_data = models.TextField(…), and the model is called MyOrm and this test_data contains data which is actually string, some holds JSON data, and some reference to blob-url. Now I’m trying to streamline my data. So I want to filter all the MyOrm object whose test_data ain’t JSON. I’m just storing/trying to store some

Django – store.models.Customer.MultipleObjectsReturned: get() returned more than one Customer — it returned 2″

I am trying to make an e-commerce website where “AnonymousUser” or Guest user can order and check out products by providing their name, email, and address. But after clicking the “Make Payment” button, my terminal was having an error that says “store.models.Customer.MultipleObjectsReturned: get() returned more than one Customer — it returned 2!” When I try to login and do the

Django Model method that uses data from the model

I want to generate unique codes (e.g. “DXGH”) and save it as a field in one of my models. The problem I have is that I do not know how to check against previously generated codes whenever a new object is created. Currently my models.py looks something like this: Ideally I would set the default value of room_code to code_gen_unique,

Advertisement