Auto-filling a form in Django Template
📁 Advanced Python Topics
Good afternoon.
There is a user profile form. When displaying it on the screen, it needs to be filled with the current user's data. How can this be done?
class Profile(models.Model): user = models.OneToOneField(User) img = models.ImageField(upload_to='user_pic/', blank=True, verbose_name='avatar') phone = models.IntegerField(max_length=10, verbose_name=u'contact phone')class ProfileForm(forms.Form): first_name = forms.CharField(label=u'Name', max_length=30, required=True Here's another option (one-liner):
df = (df .query(""Product in @dict1.keys()"") .assign(Product=lambda x: x[""Product""].replace(dict1)))Result:
In [84]: dfOut[84]: Product Price0 tr 100001 mt 50002 c 230003 c 150006 tr 8000 Log in to leave an answer
Blogs
Working with JSON in Java: Parsing and Serialization for Beginners
Checking for a String in a TypeScript Array: Optimization and Speed
Algorithms and Data Structures in C++ for Beginners: A Complete Guide
Go for Machine Learning: Capabilities and Limitations in Practice