On Thu, 24 May 2012 23:19:16 -0700 (PDT), doniyor
<doniyor.v.j@googlemail.com> declaimed the following in
gmane.comp.python.django.user:
> hey guys,
> i need to loop over the number of ids of objects in my db table and create
> accordingly the same number of html fields. how can i do it.. my effort is
> this:
> numberOfIds = Produkt.objects.count()
> i = 1;
This initializer is useless as...
> for i in range(0,numberOfIds):
... you just used the name for the loop index ...
> p = Produkt.objects.get(id=i)
... and the first value you attempt to retrieve is "0" (I'm not
familiar with any DBMS that uses 0 as a value for an autoincrement
primary key field; furthermore, looping over the /count/ of records is
erroneous -- since primary keys do not have to be contiguous if there
have been deletions in the database)...
> #lookup in db and create html input field depending on the #of
> ids.
> i=i+1
... and which also makes this increment operation void...
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment