Upgrading django from 1.8 to 2.2.0

101 views
Skip to first unread message

Santhosh sridhar

unread,
Jan 31, 2020, 5:53:08 AM1/31/20
to Django users
Hi, 
Im upgrading my django project from 1.8 to 2.2.0. I have done the below changes.

1. Added on_delete to all the Foreign Key fields
2. Changed the url reverse import as from django.urls import reverse
3. Included path/re_path instead of url in all the app's url files.
4. Changed the MIDDLEWARE_CLASSES import in settings files to MIDDLEWARE = {}

I tried to run the server, still it says "TypeError: __init__() missing 1 required positional argument: 'on_delete' and it is pointing to /usr2/santhosh/myproject/myapp/migrations/0002_abc.py

What should I do now? Do I need to delete all the migration files and re-run python manage.py migrate or what?? Help me you are aware.

Regards,
Santhosh

Mike Dewhirst

unread,
Jan 31, 2020, 6:01:46 AM1/31/20
to django...@googlegroups.com
On 31/01/2020 9:53 pm, Santhosh sridhar wrote:
> Hi,
> Im upgrading my django project from 1.8 to 2.2.0. I have done the
> below changes.
>
> 1. Added on_delete to all the Foreign Key fields
> 2. Changed the url reverse import as from django.urls import reverse
> 3. Included path/re_path instead of url in all the app's url files.
> 4. Changed the MIDDLEWARE_CLASSES import in settings files to
> MIDDLEWARE = {}
>
> I tried to run the server, still it says "TypeError: __init__()
> missing 1 required positional argument: 'on_delete' and it is pointing
> to /usr2/santhosh/myproject/myapp/migrations/0002_abc.py

There is nothing stopping you from adding the same arg to teh migration
file as you added to the model field concerned.

I frequently go back and edit migration files when all that's changed
for example is some help_text. I prefer to keep the number of migration
files as low as reasonable.



>
> What should I do now? Do I need to delete all the migration files and
> re-run python manage.py migrate or what?? Help me you are aware.
>
> Regards,
> Santhosh
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users...@googlegroups.com
> <mailto:django-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b907f25b-ffd3-462b-b3e9-5d87a20dd942%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b907f25b-ffd3-462b-b3e9-5d87a20dd942%40googlegroups.com?utm_medium=email&utm_source=footer>.

אורי

unread,
Feb 2, 2020, 10:47:30 AM2/2/20
to django...@googlegroups.com
Upgrade Django from 1.8 to 1.9, then 1.10 etc. until 2.2. Each time run makemigratons and migrate and run your tests to see that everything works. And if there is a problem with a specific migration - maybe you have to edit it manually like Mike suggested.

From my experience, it takes time to upgrade Django and it's an average of about half a day per version. And if it's 6 versions you're upgrading, it can take you around 3 days to upgrade.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b907f25b-ffd3-462b-b3e9-5d87a20dd942%40googlegroups.com.

אורי

unread,
Feb 2, 2020, 10:50:25 AM2/2/20
to django...@googlegroups.com
By the way, each time upgrade to the latest release of each version. So it's 2.2.9 you should use. And all the latest versions on https://www.djangoproject.com/download/ (1.9.13 etc.)


On Fri, Jan 31, 2020 at 12:53 PM Santhosh sridhar <santhos...@gmail.com> wrote:
--

אורי

unread,
Feb 2, 2020, 11:09:15 AM2/2/20
to django...@googlegroups.com
When you upgrade Django with pip, you can install the latest version of 1.9 with `pip install --upgrade "Django>=1.8,<1.10"` and then the same for each version, until you want the latest version of 2.2 and then use "Django>=1.8,<3.0". (actually the 1.8 is not needed here, you can also use 2.2 etc.)


On Fri, Jan 31, 2020 at 12:53 PM Santhosh sridhar <santhos...@gmail.com> wrote:
--

Maqdum Adewale

unread,
Feb 2, 2020, 11:20:13 AM2/2/20
to django...@googlegroups.com
i dont know why any time i run my django website with opra_mini browser it always bring source code

Reply all
Reply to author
Forward
0 new messages