#28997: NameError: name 'last_property' is not defined
----------------------------+--------------------------------------
     Reporter:  agplacid    |                    Owner:  nobody
         Type:  Bug         |                   Status:  closed
    Component:  Migrations  |                  Version:  2.0
     Severity:  Normal      |               Resolution:  invalid
     Keywords:              |             Triage Stage:  Unreviewed
    Has patch:  0           |      Needs documentation:  0
  Needs tests:  0           |  Patch needs improvement:  0
Easy pickings:  0           |                    UI/UX:  0
----------------------------+--------------------------------------
Changes (by Tim Graham):

 * status:  new => closed
 * resolution:   => invalid


Old description:

> Hi everyone, my first post here, I hope you are all doing great. I am
> writing a shortlet App and I want each property that is added to the app
> to have a unique generated ID with my initial parameters. I have written
> the following code but I am get this error when I run makemigrations
> "NameError: name 'last_property' is not defined"
>
> Here is the code, please I need help to resolve this.
>
> def increment_property_number():
>    last_property = Property.objects.all().order_by('id').last()
>    if not last_property:
>      return 'KSL' + str(datetime.date.today().year)
> str(datetime.date.today().month).zfill(2) + '0000'
> property_id = last_property.property_id
> property_int = int(prperty_id[9:13])
> new_property_int = property_int + 1
> new_property_id = 'KSL' + str(str(datetime.date.today().year))
> str(datetime.date.today().month).zfill(2) +
> str(new_property_int).zfill(4)

New description:

 Hi everyone, my first post here, I hope you are all doing great. I am
 writing a shortlet App and I want each property that is added to the app
 to have a unique generated ID with my initial parameters. I have written
 the following code but I am get this error when I run makemigrations
 "NameError: name 'last_property' is not defined"

 Here is the code, please I need help to resolve this.
 {{{
 def increment_property_number():
    last_property = Property.objects.all().order_by('id').last()
    if not last_property:
      return 'KSL' + str(datetime.date.today().year)
 str(datetime.date.today().month).zfill(2) + '0000'
 property_id = last_property.property_id
 property_int = int(prperty_id[9:13])
 new_property_int = property_int + 1
 new_property_id = 'KSL' + str(str(datetime.date.today().year))
 str(datetime.date.today().month).zfill(2) + str(new_property_int).zfill(4)
 }}}

--

Comment:

 Please see TicketClosingReasons/UseSupportChannels for ways to get help.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28997#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/066.5bc5a2710e8c7518f7a44bd91e91222b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to