2👍
def __str__(self):
return 'City: ' + self.get_city_en()
You want the result of the function call. What you’re doing is trying to concatenate a function with a string. Consider:
def foo():
return "test"
print foo # <function foo at 0x1052b0aa0>
print foo() # "Test"
0👍
Got my answer thanks to @Kit Sunde. Had 2 mistakes. Corrected code below:
return 'City: ' + self.get_city_en()
searched_city = CityLanguage.objects.filter(city_language__exact='EN', city__exact=self)
I was trying to reference the CityLanguage table by specifying models.CityLanguage which is incorrect. Should just be CityLanguage.
- [Answered ]-Django – grabbing error message from MySQL trigger via handling OperationalError
- [Answered ]-How to strip(not remove) specified tags from a html string using Python?
- [Answered ]-How to get a value of a model field in django actions?
Source:stackexchange.com