-
Notifications
You must be signed in to change notification settings - Fork 0
/
kapital.py
40 lines (32 loc) · 1.06 KB
/
kapital.py
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
import os
import django
from bs4 import BeautifulSoup
# Set up the Django environment
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
django.setup()
from clubbing.models import City, Club # Replace 'your_app' with the actual app name
# Function to extract club information remains the same
# The city "Madrid" is already in your database
city = City.objects.get(city_name='Madrid')
# The extracted club information
club_info = {
'Name': 'Kapital',
'Address': 'Calle de Atocha, 125, 28012 Madrid, Spain',
'Contact info': '+34 914 20 29 06',
'Type': 'Nightclub',
'Times': 'Wed - Sun: 11 pm - 6 am'
}
# Create or update the Club instance
club, created = Club.objects.update_or_create(
name=club_info['Name'],
defaults={
'city': city,
'address': club_info['Address'],
'contact_info': club_info['Contact info'],
'type': club_info['Type']
}
)
if created:
print(f"Club {club.name} created successfully with id {club.id}")
else:
print(f"Club {club.name} already exists or updated.")