If there are 4 rows which have categorycode="blah" and
citycode="blah-blah", then the space code will be something like this,
LMblahblah-blah1, LMblahblah-blah2, LMblahblah-blah3, LMblahblah-blah4.
But if you delete row with spacecode different from LMblahblah-blah4, then
your code will generate space code LMblahblah-blah4

On Fri, 19 Feb 2021, 16:07 Chetan Ganji, <ganji.che...@gmail.com> wrote:

> Yes kritika show all the models.
>
> How shubham?
> If an entry is deleted, unique code will also be deleted. Next time it
> gets generated, it might be assigned to different entry, but it still be
> unique.
>
> As kritika clarified already, so it wont be a problem.
>
> On Fri, Feb 19, 2021, 3:58 PM shubham vashisht <shubhva...@gmail.com>
> wrote:
>
>> Chetan
>> If any row is deleted from the table, then your logic will fail to return
>> the unique code
>>
>> On Fri, 19 Feb 2021, 15:52 Chetan Ganji, <ganji.che...@gmail.com> wrote:
>>
>>> Hi Kritika
>>>
>>> Ye chanel mein firangi log bhi hai, unko hinglish kaisa samjhenga? 😂
>>>
>>> Teko field pe unique constraint lagana padenga
>>>
>>> Teko no wapas 1 se start karneke liye query maarana padenga
>>>
>>> last_no = Model.objects.filter(categorycode="blah",
>>> citycode="blah-blah").count()
>>>
>>> unique_code ="LM" + categorycode
>>> + citycode + str(last_no + 1)
>>>
>>>
>>> Aisa code likkha toh result milenga 😋
>>>
>>>
>>> On Fri, Feb 19, 2021, 3:31 PM Kritika Paul <rkritikapau...@gmail.com>
>>> wrote:
>>>
>>>>  I have to create a unique code for each space saved in dbAb db me save
>>>> krne k lie, wo multiple part me save ho rha hai, multiple models bhi hai
>>>> uske.1st model se mujhe space category ka name uthana hai
>>>> 2nd se city code
>>>> Category alag alg ho skti hai
>>>> To code genrate hoga LM-categorycode-citycode-00001Next time jb
>>>> category, B hogi to number 1 se hi start hoga, ni to category same hai to
>>>> fr se 2 allot ho jaega
>>>> Eg Category - CW, COM
>>>> City - Noida, DelhiSpace 1 - Cw category
>>>> Code space 1- LMCWNoida00001Space2 - CW Category
>>>> CODE SPACE2 - LMCWDelhi00002Space 3 - COM category
>>>> CODE SPACE 3- LM-COM-NOIDA0001
>>>>
>>>> --
>>>> 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/690debd2-46e0-497f-92a8-3abbc391b97dn%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/django-users/690debd2-46e0-497f-92a8-3abbc391b97dn%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
>>> 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/CAMKMUjs6q%2B6Xer6-MRu%3DYjhKq5EYNXahEji%2BY5HBerTaNQ1Law%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAMKMUjs6q%2B6Xer6-MRu%3DYjhKq5EYNXahEji%2BY5HBerTaNQ1Law%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>> --
>> 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/CAJW_r64v1-f85ViX%2BnCFdBrupiXi5Ba%3Dzec6xoSvuZnR1jaMEg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAJW_r64v1-f85ViX%2BnCFdBrupiXi5Ba%3Dzec6xoSvuZnR1jaMEg%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> 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/CAMKMUjsJR2B7LDHujo_bXxyh1s7WZMqMwgENMQmwiX%3Dpe5QHTg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAMKMUjsJR2B7LDHujo_bXxyh1s7WZMqMwgENMQmwiX%3Dpe5QHTg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAJW_r671m7KANhpAdSPuG7AabVacUOsVcgdhPgH2j8HruNkOgQ%40mail.gmail.com.

Reply via email to