我有一个特定的场景,我无法弄清楚如何解决这个问题,某些方向将会有很大的帮助:
我有一个模特:
class RollNumber(models.Model):
r_no_prefix = models.CharField(max_length=10, verbose_name='Roll number
suffix')
r_no= models.IntegerField(verbose_name='Number')
r_no_suffix = models.CharField(max_length=10, verbose_name='Roll number
prefix')
def __unicode__(self):
return '%s -%s-%s' % (self.r_no_prefix,self.r_no,self.r_no_suffix)
不,我想要通过要求用户在没有任何上述模型字段的表单中输入以下内容来批量生成这些卷号。
Number of roll numbers you want to generate: ____________
Roll number prefix: ________________
Roll number suffix: ________________
[SUBMIT][CANCEL]
答案 0 :(得分:0)
不要使用模型表单,使用简单的表单并在循环中创建对象。像这样:
$(document)
.ready(function() {
$("#btnDownload").click(function () {
var file = $("#FilePath").val();
$.ajax({
url: '@Url.Action("DownloadCampaign", "FileList")',
data: { filePath: file, mode:'action' },
method: 'GET',
dataType: 'json',
//contentType: 'application/json; charset=utf-8',
success: function(data) {
@*window.location = '@Url.RouteUrl("DownloadCampaign", "FileList", new { filePath = data1.fileName })';*@
window.location.href = "@Url.RouteUrl(new
{ Controller = "FileList", Action = "DownloadCampaign" })/?filePath=" + data.fileName + "&mode=download";
$("#downloadFile_dialog").dialog("close");
},
error: function (req, status, errorObj) {
alert("Error");
}
});
});
});