I have a question... Concerning the @property In a case where i need to populate the full name in the serializer for my Django project, i did source="user.fullname". It worked fine as a related field. Here comes my blocker: I decided to use full name to be part of filter fields.. i did "user__fullname" . I was getting error. I know the full name was a dynamic function annotated wjrb the @property and not really part of the user model fields. How do i find my way out of this ?
The filtering won't work with what you decorate with at property because 1.it's a computed readonly attribute 2. It's not part of the model field as specified in the error. Different ways to go about it depending on the requirements. Create a custom method for fullname Filtering. It takes the fullname and use annotation to filter against queries retrieved.
I have a question we can just use mylist=[1,2,3,4] for i in range(mylist): Print (i) It will give the result why you use Rangeiterator class example it's little confusing..
I believe you intend to write: mylist=[1,2,3,4] for i in range(len(mylist)): print (i) This will return the indices. Try to run it. The key point here it to understand how iter() and next()
Support Me and The Channel:
Don't forget to Like, Comment, and Subscribe.
► Recommended Books 📜
Books: ridwanray.com/books
- Python Crash Course: amzn.to/3vLYnP9
- Python Tricks: amzn.to/48KvSA2
- Automate the boring stuff : amzn.to/3SqJzhH
- Clean Code: amzn.to/3vG5Te9
- Clean Architecture: amzn.to/3vHu9wC
► Setups 💻
Camera: Sony ZV-E10 amzn.to/4257Vkn
Monitor: Sceptre 30-inch Curved Gaming amzn.to/491KeeP
Monitor: Dell UltraSharp U2719D amzn.to/3OdA7LY
Mic: Shure MV7 amzn.to/4b8i2J2
🌐 Connect:
Website: ridwanray.com
LinkedIn: linkedin.com/in/ridwanray
Github: github.com/ridwanray
Articles:
ridwanray.com/blog
Consider subscribing for more educational content.
Well explained and detailed
Thank you. You just helped me replace my nested for loops in my project 😆
I'm glad you find it helpful. Kindly consider subscribing and sharing so that we can reach a wider audience. Thanks
Very detailed. Thanks for sharing. ❤
I'm glad you enjoyed it.
Great Content!
Glad you enjoyed it
I have a question...
Concerning the @property
In a case where i need to populate the full name in the serializer for my Django project, i did source="user.fullname". It worked fine as a related field.
Here comes my blocker:
I decided to use full name to be part of filter fields.. i did "user__fullname" . I was getting error. I know the full name was a dynamic function annotated wjrb the @property and not really part of the user model fields.
How do i find my way out of this ?
The filtering won't work with what you decorate with at property because
1.it's a computed readonly attribute
2. It's not part of the model field as specified in the error.
Different ways to go about it depending on the requirements.
Create a custom method for fullname Filtering. It takes the fullname and use annotation to filter against queries retrieved.
@@ridwanray Thanks chief
You're welcome.
I have a question we can just use
mylist=[1,2,3,4]
for i in range(mylist):
Print (i)
It will give the result why you use Rangeiterator class example it's little confusing..
I believe you intend to write:
mylist=[1,2,3,4]
for i in range(len(mylist)):
print (i)
This will return the indices. Try to run it.
The key point here it to understand how iter() and next()
@@ridwanray ohhh thanks ☺️
You are welcome
Thank you
You are welcome.
good work
I'm glad you liked it.
Thanks.