What is the difference between the below two url patterns in django?
url(r'^$', views.indexView, name='index'),
url(r'', include('registration.urls'))
To my understanding both '^$' and '' refer to a empty string. What does '^$' and '' specify actually?
^$
means nothing is between the start and end ... this only matches the empty string''
means an empty string(but does not specify anything about the beginning or end of the entire string) so when you encounter anything in the string it say well that matches'asdasd'
for example has a matching empty string at the beginning... the remaining is passed to the new url rules script (in this case everything remains)if instead your second rule was
'a'
then it would match the first a in theasdasd
and passsdasd
to the new url matching rule-setdisclaimer that this is probably a gross oversimplification, but basically true