The problem you have is that you are using regular expressions in path () that is new to Django 2 as you indicated. this only understands url addresses written in the common form, example 'myapp / index /', if you want Django to understand the routes with regular expressions you should define them with re_path (). In your case it would be
from django.urls import re_path
re_path(r'^$',views.index,name='index')
Assuming you have a Django project where you have created an app called myapp with an index view, your urls.py of the general project should look like this:
from django.urls import include, path
from django.contrib import admin
urlpatterns = [
path('admin/', admin.site.urls),
path('myapp/', include('myapp.urs'), /aqui especificas las urls de myapp/*
]
and in your application (in this case myapp) you create a file called urls.py and if it does not exist where you will put the routes belonging to that specific app that would be as follows.
from django.urls import path
from myapp import views
urlpatterns = [
path('', views.index, name='index'),
]
if you remember in urls.y of the general project we declare path('myapp/', include('myapp.urs')
this means that whatever myapp / go to urls.y of myapp and resolves, in my app there is an empty path path('', views.index, name='index'),
that calls index , so when you put localhost:8000/myapp
you should leave the index view