Need guidance

2021-05-20 Thread Muhammad Shehzad
I wanna to store multiple value in django model using DRF e.g. i have to choose three days from a week. I am using django rest framework. I have tried many solution but failed 1. Which field i have to implement in django model? CharField? Postgre ArrayField? 2. How to serialize the data to s

Re: Abstract base user

2021-09-15 Thread Muhammad Shehzad
class UserManager(DjangoUserManager): def create_one_user(self, username, email, password, **extra_fields): return self._create_user( username, email, password, type="one", **extra_fields ) def create_two_user(self, username, email, password, **extra_fields): return self._create_user( username, em

Unable to add token headers to graphene-django test using pytest

2021-10-04 Thread Muhammad Shehzad
*I am trying to add a token to graphene-django headers using pytest. But It always return that user is anonymous as shown at the end but it should return user as token is added in fixture@pytest.fixture def client_query(client): def func(*args, **kwargs): return graphql_query(*args, **kwargs, clien

Re: Is there a function that returns common elements in multiple lists

2022-01-26 Thread Muhammad Shehzad
Use intersection On Wed, Jan 26, 2022, 4:06 PM bnmng wrote: > Thank you. I think I'll go with sets as advised, although this method > also looks very neat: > intersection = [item for item in list1 if item in list2] found at > https://datagy.io/python-intersection-between-lists/ > > > > > On Tue

Re: Is there a function that returns common elements in multiple lists

2022-01-26 Thread Muhammad Shehzad
a = [1,2,3,4] b = [3,4,5,6] Convert list a to set a_set = set(a) print(a_set.intersection(b)) On Wed, Jan 26, 2022, 5:47 PM Muhammad Shehzad wrote: > Use intersection > > On Wed, Jan 26, 2022, 4:06 PM bnmng wrote: > >> Thank you. I think I'll go with sets as advise