单击弹出窗口中的按钮后删除django中的项目

时间:2018-04-29 01:10:40

标签: javascript html css django

我想创建一个弹出窗口,然后点击按钮' Dissolve'。弹出窗口应该说:'您确定要删除此字段吗?'并有两个按钮:Okay和Cancel。如果选择取消,则应该关闭弹出窗口。如果单击“确定”,则应该重定向到上一页并在上一页的表中删除该作业。

我目前的按钮代码是:

 <button type="button" class="btn btn-primary">Dissolve</button>

我目前在module.py中的工作代码是:

class Job(models.Model):
def __unicode__(self):
    return self.name
name = models.CharField('Job Name',max_length=128)
# when the job was created
date_created = models.DateTimeField('Date Created', auto_now=True)
# what entity/organization needs this job?
client_organization = models.CharField('What organization do you represent?', max_length=64)
# short description
description = models.TextField('Job Description', max_length=256)
# end product to be delivered
deliverable = models.TextField('Deliverable', max_length=256)
# when Job is due for completion
duedate = models.DateTimeField('Date Due')
# all persons who may be affected by project
#stakeholders = models.TextField('Stakeholders')
# important technical requirements
#additional_information = models.TextField('Additional Information', blank = True)
# budget estimate
#budget = models.CharField('Budget', max_length=64)
# file attachments
#attachments = models.FileField(upload_to='job', blank = True)
creator = models.ForeignKey(User,related_name = 'jobs')
organizations = models.ManyToManyField(Organization, through = 'JobRequest', blank=False, null=True)
#organizations = models.CharField(default="nothing",null=True,max_length = 256)
contact_information = models.CharField('Contact Information', max_length = 256, blank = False, null=True)
skill_required = models.CharField('Volunteer skills required', max_length=256, blank = False, null=True)
hours_day = models.CharField('Number of hours per day', max_length=256, blank = False, null=True)
#  Job is closed after a jr is confirmed
closed = models.BooleanField(default = False)
# some tags to determine what organizations to submit job to
categories = models.ManyToManyField(Category, related_name = 'jobs')
#categories = models.CharField(default="nothing",null=True, max_length = 256)
status = models.IntegerField(default = 0, choices = ((0, 'Pending'), (1, 'Approved'), (2, 'Disapproved'), (3, 'Closed')))
active = models.BooleanField(default = False)
class Meta:
    permissions = (
        ( 'view_job','Can view Job' ),
        ( 'edit_job','Can edit Job'),
        ( 'is_creator', 'Is a creator of Job')
        )

我上一页HTML的当前代码是:

  <div class="col-sm-6">
<div class="panel panel-primary">
  <div class="panel-heading">
    Your Jobs
  </div>
  <div class="panel-body">
    <ul class="list-group">
      {% for job in jobs %}
      <a class="list-group-item" href="{% url 'job_dash' job.id %}">
        {{ job.name }}
      </a>
      {% endfor %}
      <br>
      <a href = '/job_creation' class="btn btn-danger"> <i class="fa fa- 
     plus"></i> Create Job</a>
    </ul>
  </div>

0 个答案:

没有答案