将JSON数据从模板传递到django视图

时间:2016-04-18 07:05:25

标签: python angularjs django django-views

我的表中有一个CHAR数据类型的属性值。

我想发布我从HTTP获取的html模板中的字符串数据,我使用angularjs。

当我点击按钮提交时,我收到了错误

do {
    final long startTime = System.nanoTime();
    result = twitter.search(query);
    statuses = result.getTweets();
    for (Status status : statuses) {
        tweet = new Tweet(status);
        userProfile = new UserProfile(status.getUser());

        imageDownloader.getMedia(tweet.mediaEntities);
        imageDownloader.getProfilePhoto(userProfile.ProfileImageUrl);

        System.out.println(tweet);
        System.out.println(userProfile);
    }
    final long duration = System.nanoTime() - startTime;
    if ((5500 - duration / 1000000) > 0) {
        logger.info("Sleep for " + (6000 - duration / 1000000) + " miliseconds");
        Thread.sleep((5500 - duration / 1000000));
    }
} while ((query = result.nextQuery()) != null);

`ValueError: invalid literal for int() with base 10:''` 

这是我的模板:

ValueError: invalid literal for int() with base 10: 'undefined:undefined'

我尝试在view.py

中打印该值
<div class="form-group" id="location">
                          <label >Location {{l.location_name}}</label>


                          <select class="form-control" ng-model="l.location_name" id="location_name" name="location_name">
                            <option ng-repeat="l in LocationList track by l.location_name" value='{{l.location_name}}'>{{l.location_name}}</option>
                          </select>
                       </div>

结果:

print form.cleaned_data['location_name'] + "--> LOCATION NAME"

1 个答案:

答案 0 :(得分:0)

看起来你的表格期待一个int,你传递一个字符串。