Missing 1 required positional argument: 'on_delete'


#1

As I have successfully now deployed my code based on HelloWebApp to Heroku, I thought I would make a start on the Hellowebapp Intermediate Concepts book.
However, I have came across a couple of problems at the moment and there could be more.
One of the first I came across was the following:-

  File "/home/david/projects/boat/triplog/models.py", line 25, in Social
    trip = models.ForeignKey(Trip, related_name="social_accounts")
TypeError: __init__() missing 1 required positional argument: 'on_delete'

I believe this will be referring to the on_delete=CASCADE etc

I have also come across the fact that url is in the process of being deprecated in favour of re-path().
I actually did notice that the code on Github has changed and I can understand that it must be difficult keeping the book updated as django is quite a fast moving target.
I did find this rather useful link for help with the changes in url, path and re-path:-

https://consideratecode.com/2018/05/02/django-2-0-url-to-path-cheatsheet/

Are there any plans to update the intermediate concepts book?


#2

Should be updated in the most recent PDF version. You have a login to the HelloWebBooks.com dashboard, right? Can you redownload the PDF for IC and check to see if it has been updated?


#3

Hi Tracy,
No it’s still the original - First Edition (1.0).
It still has the old style of doing the urls, but your code on github is up to date, I think.

url(r’^things/(?P<slug>[-\w]+)/edit/images/$’,

Regards

Dave


#4

I have just checked and the latest available from Leanpub was last updated on 2018-04-16 but the but on the dashboard, it’s still the original 2015 version 1.0.

I have also spotted some git output which I don’t doubt should be there, at the bottom of the views.py in the github hellowebappIC code. :-)

Dave