Skip to content

Commit 97fa286

Browse files
committed
Moved to Django 2
1 parent bd23eae commit 97fa286

File tree

7 files changed

+41
-29
lines changed

7 files changed

+41
-29
lines changed

apps/events/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def upcoming(self):
2727

2828
class Event(TimeStampedModel):
2929
name = models.CharField('Название события', max_length=256)
30-
city = models.ForeignKey(City)
30+
city = models.ForeignKey(City, on_delete=models.CASCADE)
3131
date = models.DateTimeField('Начало события', blank=True, null=True)
3232
is_active = models.BooleanField('Отображается на сайте', default=True)
3333
url = models.URLField('Ссылка на событие', blank=True)

apps/meetups/models.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class Speaker(TimeStampedModel):
1919
last_name = models.CharField(max_length=256)
2020
contact_url = models.CharField(max_length=256, null=True, blank=True)
2121
avatar = models.ImageField(upload_to='speaker_avatars')
22-
employer = models.ForeignKey('Employer', related_name='speakers')
22+
employer = models.ForeignKey('Employer', related_name='speakers', on_delete=models.CASCADE)
2323

2424
@property
2525
def full_name(self):
@@ -34,8 +34,10 @@ class Meta:
3434

3535

3636
class Talk(TimeStampedModel):
37-
event = models.ForeignKey('events.Event', related_name='talks')
38-
speaker = models.ForeignKey('Speaker', related_name='talks')
37+
event = models.ForeignKey(
38+
'events.Event', related_name='talks', on_delete=models.CASCADE)
39+
speaker = models.ForeignKey(
40+
'Speaker', related_name='talks', on_delete=models.CASCADE)
3941
title = models.CharField(max_length=256)
4042
description = models.TextField()
4143
slides_url = models.CharField(

apps/meetups/templates/meetups/event_detail.html

100755100644
File mode changed.

apps/news/admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from django.contrib import admin
2-
from django.core.urlresolvers import reverse
2+
from django.urls import reverse
33
from django.utils.html import format_html
44
from django.utils.translation import ugettext as _
55

python_ru/settings.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
1414
import os
1515

16-
import dj_database_url
1716
import sys
17+
import dj_database_url
1818

1919
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
2020

@@ -28,7 +28,7 @@
2828
# SECURITY WARNING: don't run with debug turned on in production!
2929
DEBUG = os.environ.get('DEBUG', True)
3030

31-
ALLOWED_HOSTS = ['.python.ru']
31+
ALLOWED_HOSTS = ['.python.ru', '127.0.0.1']
3232

3333
# Application definition
3434

@@ -133,16 +133,22 @@
133133
# Static files (CSS, JavaScript, Images)
134134
# https://docs.djangoproject.com/en/1.8/howto/static-files/
135135

136+
136137
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
137-
STATICFILES_DIRS = (os.path.join(BASE_DIR, "assets"),)
138+
139+
STATICFILES_DIRS = (
140+
os.path.join(BASE_DIR, 'assets'),
141+
)
138142
STATIC_URL = '/static/'
139143

140144
# Simplified static file serving.
141145
# https://warehouse.python.org/project/whitenoise/
142146
if not sys.argv[0].endswith('py.test'):
143147
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
144148

145-
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
149+
MEDIA_ROOT = (
150+
os.path.join(BASE_DIR, 'media'),
151+
)
146152
MEDIA_URL = '/media/'
147153

148154
LOGGING = {

python_ru/urls.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from django.conf.urls.static import static
44
from django.contrib import admin
55

6+
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
7+
68
from apps.news import views as news_views
79

810

@@ -11,5 +13,7 @@
1113
url(r'^meetups/', include('apps.meetups.urls')),
1214
url(r'^junior/$', news_views.JuniorView.as_view(), name='junior'),
1315

14-
url(r'^admin/', include(admin.site.urls)),
16+
url(r'^admin/', admin.site.urls),
1517
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
18+
19+
urlpatterns += staticfiles_urlpatterns()

requirements.txt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
Django==1.9.8
2-
psycopg2==2.6.2
3-
dj-database-url==0.4.1
4-
gunicorn==19.6.0
5-
whitenoise==3.2
6-
django-model-utils==2.5
1+
Django==2.0.1
2+
psycopg2==2.7.3.2
3+
dj-database-url==0.4.2
4+
gunicorn==19.7.1
5+
whitenoise==3.3.1
6+
django-model-utils==3.0.0
77
feedparser==5.2.1
88
Pillow==4.0.0
9-
python-dateutil==2.5.3
10-
lxml==3.6.1
11-
bleach==1.4.3
12-
html5lib==0.9999999
13-
requests==2.10.0
14-
codecov==2.0.5
15-
pytest_django==2.9.1
16-
pytest-cov==2.3.0
17-
factory_boy==2.7.0
18-
vcrpy==1.9.0
19-
pytest-flake8==0.6
20-
pytz==2016.6.1
9+
python-dateutil==2.6.1
10+
lxml==4.1.1
11+
bleach==2.1.2
12+
html5lib==1.0.1
13+
requests==2.18.4
14+
codecov==2.0.12
15+
pytest_django==3.1.2
16+
pytest-cov==2.5.1
17+
factory_boy==2.9.2
18+
vcrpy==1.11.1
19+
pytest-flake8==0.9.1
20+
pytz==2017.3
2121
readability-api==1.0.2
22-
Faker==0.7.7
22+
Faker==0.8.8

0 commit comments

Comments
 (0)