Hi Roger:

Thanks a lot! Such as easy :)

Greetings

bengoshi


On 2/14/20 2:15 PM, Roger Gammans wrote:
> Use:
>
> for data in Journal.objects.all():
>       ....
>
>
>
> On Fri, 2020-02-14 at 14:13 +0100, Kai Kobschätzki wrote:
>> Hi:
>>
>> I want to do something with the content of a table. Problem is, that
>> the
>> IDs are not continuous. I tried:
>>
>> import .models from Journal
>>
>> last = Journal.obejects.last()
>> last += 1
>> for i in range(last):
>>   try:
>>     data = Journal.objects.get(pk=i)
>>     doing something with this data
>>   except:
>>     pass
>>
>> This solution runs but it seems not smart...
>>
>> I need the try because there a gaps in the table, so I have got e.g.
>> element 1, element 3, element 8. If there is not an try/except the
>> for
>> will crash. And I need the last +=1 otherwise the last element won't
>> be
>> interpret.
>>
>> Could anyone show me how I could improve it?
>>
>> Thansk and Greetings
>>
>> bengoshi
>>
>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/10f42748-2a92-3923-2d31-177e5f32563d%40gmail.com.

Reply via email to