Why is the "default value" in view not working ?

Hi, my index view should query some data with the default "date of the day"value.
For a test, I entered a string as a default value. : “2019-08-01”
My url :

urlpatterns = [
     path('<str:date_index>', views.index, name='index'),
    ]

My view:

def get_reunions_by_date(date_r):
    return Reunion.objects.filter(datetime_start__startswith=date_r) \
        .order_by('numero', 'hippodrome__nom')

def index(request, date_index="2019-08-01"):
    year, month, day = map(int, date_index.split('-'))
    date_du_jour = date(year, month, day)
  
    return render(request, 'myapp/index.html', {
        'reunions': get_reunions_by_date(date_du_jour),
        'date_du_jour': date_du_jour
    })

Now, If I enter this url : myapp/2019-01-01, it’s working, the index template is rendered, but if I enter this url: myapp/ nothing is rendered.
Why is it not takking the default value date_index="2019-08-01" in the view ?
I don’t understand.

You’re not including any error messages you might be receiving, the rest of your urls, the content you’re actually receiving, anything at all about how you’re running this, or, if you’re running this in a dev environment, your console output from the runserver command - so it’s going to be really difficult to be sure.

But, if I were to hazard a guess, I would expect you are receiving a 404 unless you have a view assigned to myapp/.

Why? The url you post, path('<str:date_index>', views.index, name='index'), only matches if you supply a parameter in the url.

The supplied request for myapp/ does not match what you’ve defined as myapp/<str:date_index>, it would match myapp/

Ken

Yes, that’s it.
I only needed to add a second url.
``

urlpatterns = [
     path('<str:date_index>', views.index, name='index'),
     path('', views.index, name='index'),
    ]