[Python-ideas] Re: Extract variable name from itself

2023-11-08 Thread anthony.flury via Python-ideas
That is true, but of course in Django the field is an object, and it is the object that knows it's name. There is nothing to stop you declaring a field in a model called 'person_name' but also doing this in the code : user_name = instance.person_name In Django the user_name variabl

[Python-ideas] Re: Extract variable name from itself

2023-11-08 Thread Rene Nejsum
A little late, but the requirement to "Extract variable name from itself" is widely used in Django. Each field in a Django model, knows it's own variable name user_name = models.CharField(...) The instance of CharField knows that it's variable name is "user_name", so that it can name the row i