class Spaces(BaseModel):
__tablename__ = "spaces"
name = db.Column(db.String(255))
user_id = db.Column(db.Integer)
status = db.Column(
db.String(100), default=SpaceStatusType.PENDING.value)
space_category_id = db.Column(
db.Integer, db.ForeignKey("space_categories.id"))
space_company_id = db.Column(
db.Integer, db.ForeignKey("space_companies.id"))
space_detail_id = db.Column(db.Integer, db.ForeignKey("space_details.id"))
space_broker_id = db.Column(db.Integer, db.ForeignKey("space_brokers.id"))
space_building_particulars_id = db.Column(db.Integer, db.ForeignKey("space_building_particulars.id"))
space_commercial_products_id = db.Column(db.Integer, db.ForeignKey("space_commercial_products.id"))
space_document_id = db.Column(db.Integer, db.ForeignKey("space_documents.id"))
is_deleted = db.Column(db.Boolean,default=False)
is_completed = db.Column(db.Boolean,default=False)
space_category = db.relationship("SpaceCategory", backref=db.backref(
"spaces", uselist=True, lazy="dynamic"))
space_company = db.relationship("SpaceCompany", backref=db.backref(
"spaces", uselist=True, lazy="dynamic"))
space_detail = db.relationship("SpaceDetail", backref=db.backref(
"spaces", uselist=True, lazy="dynamic"))
space_broker = db.relationship("SpaceBroker", backref=db.backref(
"spaces", uselist=True, lazy="dynamic"))
space_building_particulars = db.relationship("SpaceBuildingParticular", backref=db.backref(
"spaces", uselist=True, lazy="dynamic"))
space_commercial_products=db.relationship("SpaceCommercialProduct", backref=db.backref(
"spaces", uselist=True, lazy="dynamic"))
space_document=db.relationship("SpaceDocument", backref=db.backref(
"spaces", uselist=True, lazy="dynamic"))
Need to save in name field
On Fri, 19 Feb 2021 at 16:32, Chetan Ganji <ganji.chetan@gmail.com> wrote:
Show the model where you save Space_code--On Fri, Feb 19, 2021, 4:19 PM Kritika Paul <rkritikapaul17@gmail.com> wrote:--class SpaceCategory(BaseModel):__tablename__ = "space_categories"name = db.Column(db.String(255))description = db.Column(db.Text)image_url = db.Column(db.Text)code = db.Column(db.String(100))space_sub_category = db.relationship('SpaceSubCategory', backref=db.backref("space_category", uselist=False))class Cities(BaseModel):__tablename__ = "cities"name = db.Column(db.String(255))code = db.Column(db.String(100))is_deleted = db.Column(db.Boolean,default=False)These are the models,There is one other model where I have to save Space_codeNow, Space Category is CW,COM,MSCity Code is NOIDA, DELHI,KOlkataSpace code to be generated such that Numbers should increase Space Category WiseOn Fri, 19 Feb 2021 at 16:07, Chetan Ganji <ganji.chetan@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 <shubhvas95@gmail.com> wrote:ChetanIf 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.chetan@gmail.com> wrote:--Hi KritikaYe chanel mein firangi log bhi hai, unko hinglish kaisa samjhenga? 😂Teko field pe unique constraint lagana padengaTeko no wapas 1 se start karneke liye query maarana padengalast_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 <rkritikapaul17@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+unsubscribe@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.
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+unsubscribe@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.
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+unsubscribe@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.
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMKMUjsJR2B7LDHujo_bXxyh1s7WZMqMwgENMQmwiX%3Dpe5QHTg%40mail.gmail.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-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BQJGq5O%3D6xBfVs5yDKxoTHsKQ0s-mBAthRSGQNeUEon9vA%2Bmg%40mail.gmail.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-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMKMUju7z8h1Z29Bum-782viSLLwxKHftdvobCxLYU7CjPSXig%40mail.gmail.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-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BQJGq4cidmaOwkCtLs9tOnioz7fKiVB%3D6GPhV2qZ2sSja6BGw%40mail.gmail.com.
No comments:
Post a Comment