kevinharvey / jmad

The Jazz Musicianship Archive & Database
GNU General Public License v2.0
18 stars 7 forks source link

View must be callable #11

Open datatalking opened 3 years ago

datatalking commented 3 years ago

I found a copy of your Test-Driven Django Development book and enjoy your writing. Do you have other books that I could buy as your writing style is entertaining vs most other writers are academically constipated and boring!

On page 26 it says to update demo code to the following.

from django.conf.urls import include, url from django.contrib import admin
urlpatterns = [
url(r'^$', 'solos.views.index'), url(r'^admin/', include(admin.site.urls)),
]

and it generates an error.

  File "/Users/vanessawilson/sbox/test/jmad/jmad/jmad/urls.py", line 20, in <module>
    url(r'^$', 'solos.views.index'),
  File "/Users/vanessawilson/anaconda3/lib/python3.8/site-packages/django/conf/urls/__init__.py", line 13, in url
    return re_path(regex, view, kwargs, name)
  File "/Users/vanessawilson/anaconda3/lib/python3.8/site-packages/django/urls/conf.py", line 73, in _path
    raise TypeError('view must be a callable or a list/tuple in the case of include().')
TypeError: view must be a callable or a list/tuple in the case of include().
(base) Vanessas-iMac:jmad vanessawilson$ 

I reviewed your repo and it looks like the 'url' has been deprecated and is now 'path' which I also tried but it's generating an error. If this is errata or just deprecated code, how can I update it to run? I've updated the code to where I have it with a FIXME on the URL.py file in my repo.

https://github.com/datatalking/jmad

enjay870 commented 2 years ago

I had similar issues. It may have to do with the version of Django you are using. The book works with Django 1.8. so if you have, for example, Django 3.0 or later it can cause all kinds of problems. I am planning to revert to the versions of Django, Selenium and so on set out in the requirements.txt file and hope it will all fall into place. Really we need a second edition of the book to reflect all the software updates since 2016.

kevinharvey commented 2 years ago

Thank you both for creating and responding to an issue! To echo @enjay870, this codebase is based on a very old version of Django and should be updated. However, if you are starting from Django 3.*, you probably need to use path instead of url. include should still work. https://docs.djangoproject.com/en/3.2/ref/urls/#include

datatalking commented 2 years ago

Would the authors consider updating the work, I would love to contribute, test, write, or proofread. I started self-teaching python years ago and the Django girls were very, very helpful in giving me feedback so I remember what it was like as a total beginner. Even now years later I'm much better versed in data science but relative Django noob.