From the django project web site, I am trying to implement the following code and have it spit out the dictionary form of the sql.
-- Does anyone have an example of how this is done.
The code below is from the project web page
https://docs.djangoproject.com/en/1.7/topics/db/sql/
When I execute the 2 lines below I retrieve the following
<RawQuerySet: 'SELECT first_name AS first, last_name AS last FROM person'>
Does anyone have an example so that I can get this into a dictionary format so that I can send it back to the web page for consumption?
>>> name_map = {'first': 'first_name', 'last': 'last_name', 'bd': 'birth_date', 'pk': 'id'} >>> Person.objects.raw('SELECT * FROM some_other_table', translations=name_map)
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/90ee80be-2413-4b6a-8739-2bd73a1d15b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment