LoginSignup
14
16

More than 5 years have passed since last update.

Djangoのバージョンを1.11から2.0にする

Last updated at Posted at 2018-01-04

特にむずかしいことはなかった
https://docs.djangoproject.com/ja/2.0/howto/upgrade-version/

# python
Python 3.6.1 (default, Aug 20 2017, 06:03:52) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
1.11.4
 pip install -U Django
# python
Python 3.6.1 (default, Aug 20 2017, 06:03:52) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
2.0.1

urlモジュールを使っていた部分でエラー吐くようになったので
https://docs.djangoproject.com/ja/2.0/intro/tutorial01/
この辺のurls.pyを参考にして直した

例えばこの辺り

from django.conf.urls import include, url 

urlpatterns = [                                                                  
url(r'^accounts/', include('accounts.urls')),                               

from django.conf.urls import include, path

urlpatterns = [                                                                  
path('accounts/', include('accounts.urls')),                               

こんな感じになおすとエラーが解消された

/xxxxx/models.py

もう一箇所エラーを吐いていて

hoge = models.ForeignKey(fuga)

ってやっていたところがこけ始めたので

エラーメッセージみると

TypeError: __init__() missing 1 required positional argument: 'on_delete'

って、出てきたのでDjango2.0になってon_deleteが必須の引数になったらしい

参考
https://torina.top/detail/297/

14
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
16