Friday, December 16, 2016

Re: Dynamic querysets?

you are looking for `statedict.items()`.  (Or `statedict.iteritems()` on py2)  By default a dict just loops over the keys.  And then it unpacks your two letter string into k, v.  So the first step of your loop is k='A' and v='K'.

Also, that's not how you use get.

On 12/16/2016 4:19 PM, Malik Rumi wrote:

naively thinking I would be able to do something like


for k,v in statedict:
 
if twodigit == k:
 state
= Jurisdiction.objects.get(v)

No comments:

Post a Comment