Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
284 views
in Technique[技术] by (71.8m points)

django-class-based-views - Django检查并删除(Django check and delete)

What is another way to do in django:

(django的另一种处理方式是:)

I have two models.

(我有两个模型。)

One of them includes another's key.

(其中一个包括另一个的密钥。)

Before delete this record I want to check if this record does exists in the other one and I want to do this without using 'PROTECT'.

(在删除该记录之前,我想检查该记录是否确实存在于另一个记录中,并且我想在不使用“ PROTECT”的情况下执行此操作。)

The logic is:

(逻辑是:)

count=countoffirstrecord(in secondobject)
if count=0 then
    displaymodal("Are you sure to delete this record")
    if (yes)
        deletefirstobject(pk)
    end if
    return firstobjectlistview(refresh)
else
    displaymodal("Record exists in 'secondobject')
    return firstobjectlistview(withoutrefresh)
endif
  ask by bahar translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...