equal
deleted
inserted
replaced
|
1 # -*- coding: utf-8 -*- |
|
2 ''' |
|
3 Created on Nov 14, 2012 |
|
4 |
|
5 @author: ymh |
|
6 ''' |
|
7 |
|
8 from django import forms |
|
9 from .models import VideoKCRel |
|
10 import requests |
|
11 from . import settings |
|
12 |
|
13 class VideoKCRelForm(forms.ModelForm): |
|
14 |
|
15 iri_id = forms.CharField(max_length=255, widget=forms.widgets.Select()) |
|
16 |
|
17 def __init__(self, *args, **kwargs): |
|
18 super(VideoKCRelForm, self).__init__(*args, **kwargs) |
|
19 |
|
20 url = settings.LDT_API_URL + "contents/" |
|
21 #limit=20&offset=20 |
|
22 r = requests.get(url) |
|
23 self.fields['iri_id'].widget.choices = [(content['iri_id'], content['title']) for content in r.json['objects']] |
|
24 |
|
25 class Meta: |
|
26 model = VideoKCRel |
|
27 |