forked from kavyadhariwal/Hackathon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_sample_data.py
More file actions
58 lines (52 loc) · 1.94 KB
/
add_sample_data.py
File metadata and controls
58 lines (52 loc) · 1.94 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import django
# Setup Django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'hacker.settings')
django.setup()
from hackathon.models import Category, Subcategory
# Sample categories and subcategories
categories_data = [
{
'name': 'Programming',
'subcategories': ['Python', 'JavaScript', 'Java', 'C++', 'Web Development', 'Mobile Development']
},
{
'name': 'Design',
'subcategories': ['UI/UX Design', 'Graphic Design', 'Web Design', 'Logo Design', 'Illustration']
},
{
'name': 'Business',
'subcategories': ['Marketing', 'Finance', 'Management', 'Entrepreneurship', 'Sales']
},
{
'name': 'Technology',
'subcategories': ['Artificial Intelligence', 'Machine Learning', 'Data Science', 'Cloud Computing', 'Cybersecurity']
},
{
'name': 'Creative Arts',
'subcategories': ['Photography', 'Video Editing', 'Music Production', 'Digital Art', 'Animation']
},
{
'name': 'Language',
'subcategories': ['English', 'Spanish', 'French', 'German', 'Chinese', 'Japanese']
},
{
'name': 'Health & Fitness',
'subcategories': ['Yoga', 'Nutrition', 'Fitness Training', 'Mental Health', 'Wellness']
},
{
'name': 'Education',
'subcategories': ['Teaching Methods', 'Curriculum Design', 'Student Assessment', 'Educational Technology']
}
]
# Create categories and subcategories
for cat_data in categories_data:
category, created = Category.objects.get_or_create(name=cat_data['name'])
print(f"{'Created' if created else 'Found'} category: {category.name}")
for sub_name in cat_data['subcategories']:
subcategory, created = Subcategory.objects.get_or_create(
name=sub_name,
category=category
)
print(f" {'Created' if created else 'Found'} subcategory: {subcategory.name}")
print("\n✅ Sample categories and subcategories added successfully!")