Making Serial number

63 views
Skip to first unread message

Kushal Neupane

unread,
May 2, 2020, 12:02:54 PM5/2/20
to Django users
How to make Serail Number 1, 2, 3 and respective in template? Help me. Thank you.

Jorge Gimeno

unread,
May 2, 2020, 1:36:34 PM5/2/20
to django...@googlegroups.com
On Sat, May 2, 2020 at 9:03 AM Kushal Neupane <mkus...@gmail.com> wrote:
How to make Serail Number 1, 2, 3 and respective in template? Help me. Thank you.

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/3842baeb-b054-482a-b127-ae5c160493ca%40googlegroups.com.

Models in Python have an autoincrementing primary key (unless you have turned that off).  See https://docs.djangoproject.com/en/3.0/topics/db/models/#automatic-primary-key-fields

-Jorge

Kushal Neupane

unread,
May 2, 2020, 1:38:26 PM5/2/20
to django...@googlegroups.com
Not primary key to use here.
There might be different data.
I am trying to do serial numbers as total numbers in the list. Thank you 

Jorge Gimeno

unread,
May 2, 2020, 1:44:39 PM5/2/20
to django...@googlegroups.com
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFWyajUO4aw9qdb-zx1j_DYbFMDS2WrTzs8zVd0_tB3xYjNNaw%40mail.gmail.com.

If you're looking to use the template to generate line numbers, I would start with the linenumbers template tag:  https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#linenumbers

-Jorge

victor awakan

unread,
May 2, 2020, 1:47:00 PM5/2/20
to django...@googlegroups.com
Try html ordered list with your for loop. Like this <ol></ol>

Kushal Neupane

unread,
May 2, 2020, 1:48:09 PM5/2/20
to django...@googlegroups.com
Can you give one example sir? 

Benedict Uwazie

unread,
May 2, 2020, 8:43:17 PM5/2/20
to Django users
Inside your loop pass in forloop.counter like this {{ forloop.counter }} checkout this link https://techstream.org/Bits/Loop-Counter-in-Django-View


On Saturday, 2 May 2020 18:48:09 UTC+1, Kushal Neupane wrote:
Can you give one example sir? 

On Sat, May 2, 2020, 23:30 victor awakan <victor...@gmail.com> wrote:
Try html ordered list with your for loop. Like this <ol></ol>
On Sat 2. May 2020 at 20.38, Kushal Neupane <mkus...@gmail.com> wrote:
Not primary key to use here.
There might be different data.
I am trying to do serial numbers as total numbers in the list. Thank you 

On Sat, May 2, 2020, 23:20 Jorge Gimeno <jlgim...@gmail.com> wrote:
On Sat, May 2, 2020 at 9:03 AM Kushal Neupane <mkus...@gmail.com> wrote:
How to make Serail Number 1, 2, 3 and respective in template? Help me. Thank you.

--
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...@googlegroups.com.

Models in Python have an autoincrementing primary key (unless you have turned that off).  See https://docs.djangoproject.com/en/3.0/topics/db/models/#automatic-primary-key-fields

-Jorge

--
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...@googlegroups.com.

--
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...@googlegroups.com.

--
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...@googlegroups.com.

Kushal Neupane

unread,
May 2, 2020, 11:32:38 PM5/2/20
to django...@googlegroups.com
Dear Sir, i learned and used from https://docs.djangoproject.com/en/3.0/ref/templates/builtins/#linenumbers site. But, how to make dynamic serial number? Thank you.

image.png
image.png


To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5b6a83c8-2056-4cd2-ad7c-e0a070bb04fe%40googlegroups.com.

Benedict Uwazie

unread,
May 3, 2020, 4:09:46 AM5/3/20
to Django users
Is your table row is inside a loop? If it is use {{ forloop.counter }}
Reply all
Reply to author
Forward
0 new messages