开发者

print referred variable from object in django/python

In the below python code ,can the object know that the template tag is referring a variable and get that in a python variable

newemp is the object that i am passing from the views and the template is trying to access a variable as {{newemp.get_names.emp_add}} ,now in the python code can the object print this variable i.e, emp_add

class Emp(models.Model):
   name开发者_如何学JAVA = models.CharField(max_length=255, unique=True)
   address1 = models.CharField(max_length=255)

   def get_names(self):
     logging.debug(var)          
      var=self.some referred object

     names = {}


No. The access is done once the appropriate object has been returned from get_names() so there is no direct way to know within the method what is being accessed.


If you are asking whether you can write to a variable within a template, and then access that value back within your Python code, I do not believe so. That kind of goes against the idea of templates, IMHO.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜