realpython / book2-exercises

Book 2 -- Exercises for the book
168 stars 203 forks source link

updated solution for django 2.0 ? #98

Open mm-git01 opened 6 years ago

mm-git01 commented 6 years ago

recently i encountered a include() error while passing the url to the app using django 2.0.The solutions here seem to be somewhat different since the tutorial teaches django 1.xx a newer solution would be appreciated.

i was doing the bloggy_project

varnaa commented 5 years ago

The new syntax supports type coercion of URL parameters. In the example, the view will receive the year keyword argument as an integer rather than as a string. Also, the URLs that will match are slightly less constrained in the rewritten example. For example, the year 10000 will now match since the year integers aren’t constrained to be exactly four digits long as they are in the regular expression.

The django.conf.urls.url() function from previous versions is now available as django.urls.re_path(). The old location remains for backwards compatibility, without an imminent deprecation.

_The old django.conf.urls.include() function is now importable from django.urls so you can use from django.urls import include, path, re_path in your URLconfs._