-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscripts.txt
44 lines (37 loc) · 943 Bytes
/
scripts.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#this is for pokemon
#run from django shell
from pokemon.views import *
with open('your_file.json') as fh:
data = json.load(fh)
pokeData = []
s = data[0]['model']
for i in data:
if i['model'] == s:
pokeData.append(i)
for j in pokeData:
i = j['fields']
p = Pokemon()
p.poke_name = i['poke_name']
p.poke_type = i['poke_type']
p.question_number = i['question_number']
p.save()
print(j['pk'])
#this is for Questions
#run from django shell
from pokemon.views import *
with open('queans.json') as fh:
data = json.load(fh)
qData = []
s = data[50]['model']
for i in data:
if i['model'] == s:
qData.append(i)
for j in qData:
i = j['fields']
p = Question()
p.number = i['number']
p.content = i['content']
p.difficulty_level = i['difficulty_level']
p.answer = i['answer']
p.save()
print(j['pk'])