I would not assume what "previous" means. Rather use post_save to get the
actual ID of the current recording.
On Friday, 29 May 2020 12:43:19 UTC+2, Anselme SERI wrote:
>
> Hello Derek,
> Is it possible to retrieve the id of the previous recording from this
> function? If possible I could increm
Hello Derek,
Is it possible to retrieve the id of the previous recording from this
function? If possible I could increment it to get the id of the current
recording.
Anselme S.
Le ven. 29 mai 2020 à 06:08, Derek a écrit :
> The suggested code will not work because, at this point, the "id" has no
The suggested code will not work because, at this point, the "id" has not
yet been generated by the database (unlike the other data which is
typically entered by the user).
You will need to move this code to a post_save signal function -
https://docs.djangoproject.com/en/3.0/ref/signals/#post-s
the error message is
unsupported format string passed to NoneType.__format__
Le mer. 27 mai 2020 à 13:09, Akinfolarin Stephen <
akinfolarinsteph...@gmail.com> a écrit :
> i feel in your last session you are trying to concatenate a string and an
> integer use the int function to convert it to stri
When I test the function you offer 'self.id' returns 'None'
Le mer. 27 mai 2020 à 13:09, Akinfolarin Stephen <
akinfolarinsteph...@gmail.com> a écrit :
> i feel in your last session you are trying to concatenate a string and an
> integer use the int function to convert it to string then the numbe
i feel in your last session you are trying to concatenate a string and an
integer use the int function to convert it to string then the number will
show
On Monday, May 25, 2020 at 5:48:29 AM UTC+14, Anselme SERI wrote:
>
> from django.db import models
>>
>>
>> def codeid():
>> lastid = MyMod
Hi Anselme,
On 27/05/2020 13.33, Anselme SERI wrote:
What I want to do is fill in the 'code' field of my 'Diploma' template.
For example, the first record of the model will have the value
'BAC1' in the 'code' field, the second 'BAC2', , 'BAC01653'
.
The approach I have chose
Hello,
I will try to explain it to you in the language I understand best and I
hope that you will have an excellent translator to identify me.
english version
What I want to do is fill in the 'code' field of my 'Diploma' template. For
example, the first record of the model will have the value 'BA
Its not clear what you mean by "last"; do you mean a record that already
exists in the database and has a ID value - or do you want the ID of the
current record? Either way, the code field should not be resetting the '0'
to a '1' as this is then misrepresenting the actual data.
PS The logic to
hello,
I am trying to create a function which will recover the last id of my model
which I will increment and add to a character string, and I would like to
add this new value (x = last id incremented + string) be added to the
"code" field "of my model when I make a new recording.
How else could we
Hi Anselme,
On 24/05/2020 17.48, Anselme SERI wrote:
I try to to write a correct function for my model which generate a str
+ incremental number according last id model.
Your code is obviously wrong for quite a few reasons, but I at least
simply cannot understand what you are trying to
>
> from django.db import models
>
>
> def codeid():
> lastid = MyModel.objects.last(id)
> autocode = ''
> if lastid == 0:
> autocode = 'BAC1'
> elif lastid != 0:
> if len(lastid) <= 8:
> lastid += 1
> autocode = 'D/BAC/' + la
12 matches
Mail list logo