| | 401 | |
|---|
| | 402 | # The 'select' argument to extra() supports names with dashes in them, as long |
|---|
| | 403 | # as you use values(). |
|---|
| | 404 | >>> Article.objects.filter(pub_date__year=2008).extra(select={'dashed-value': '1'}).values('headline', 'dashed-value') |
|---|
| | 405 | [{'headline': u'Article 11', 'dashed-value': 1}, {'headline': u'Article 12', 'dashed-value': 1}] |
|---|
| | 406 | |
|---|
| | 407 | # If you use 'select' with extra() and names containing dashes on a query |
|---|
| | 408 | # that's *not* a values() query, those extra 'select' values will silently be |
|---|
| | 409 | # ignored. |
|---|
| | 410 | >>> articles = Article.objects.filter(pub_date__year=2008).extra(select={'dashed-value': '1', 'undashedvalue': '2'}) |
|---|
| | 411 | >>> articles[0].undashedvalue |
|---|
| | 412 | 2 |
|---|