﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
28997	NameError: name 'last_property' is not defined	agplacid	nobody	"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)
}}}"	Bug	closed	Migrations	2.0	Normal	invalid			Unreviewed	0	0	0	0	0	0
