python - Enforce a where clause on particular column in django ORM -
Can we write a cover around the DJENGO ORM so that every query has a clause. Now, you can not have a all () method that's fine. For example, suppose we have the
auth_user table and the
user_properties table in which there is additional data about the user (and a foreign key from auth_user). Here, if a developer wants to receive some lines from the user_properties table, then it must provide the
filter query in the
user or
user_id column or If you need more information please write a comment.
If you want to increase the user mode, then the OneToOne field in you model Model Model:
class UserProperty (models.Model): user = models.OneToOneField (user, related_name = 'properties') prop1 = model.carfield (... ) Prop2 = models.CharField (...) prop1 = request.user.properties.prop1 Remember, when you create a new user, you need to create userproperty < / Div>
Comments
Post a Comment