Python/Django Not Appending Slash
Question: For some reason Django is not appending a slash at the end of variables that
contain numeric characters:

test_A -- works (goes to test_A/)  
test_1 -- does not (doesn't append the / at the end - giving me a 404)

I do have middleware installed and APPEND_SLASH = True.

Any thoughts? Thanks!

url.conf:

    
    
    from django.conf.urls import patterns, url
    from dashboard import views
    
    urlpatterns = patterns('',
        url(r'^$', views.index, name='index'),
        url(r'^environment/(?P<environment_name_url>\w+)/$', views.environment, name='environment'),)
    

models.py:

    
    
    from django.db import models
    
    class Environment(models.Model):
    name = models.CharField(max_length=128, unique=True)
    def __str__(self):
        return self.name
    

views.py:

    
    
    def environment(request, environment_name_url):
        environment_name = environment_name_url.replace('_', ' ')
        context_dict = {'environment_name': environment_name}
        try:
            environment = Environment.objects.get(name=environment_name)
            pages = Page.objects.filter(environment=environment)
            context_dict['pages'] = pages
            context_dict['environment'] = environment
        except Environment.DoesNotExist:
            pass
        return render(request, 'dashboard/environment.html', context_dict)
    

Error:

    
    
    Using the URLconf defined in dashboard_project.urls, Django tried these URL patterns, in this order:
    
        1. ^admin/
        2. ^dashboard/ ^$ [name='index']
        3. ^dashboard/ ^environment/(?P<environment_name_url>\w+)/$ [name='environment']
        4. media/(?P<path>.*)
    
    The current URL, dashboard/environment/test_1, didn't match any of these.
    


Answer: You have to extend your regular expressions. The problem is not that the slash
is not appended, the problem is that none of the urls matches (with or without
the slash).

Simple solution, to include the dot you should update your regular expression
to also allow a dot: `url(r'^environment/(?P<environment_name_url>[\w\.]-)/$',
views.environment, name='environment'),)`

Your could improve it further to also allow a dash:
`url(r'^environment/(?P<environment_name_url>[\w\.-]+)/$', views.environment,
name='environment'),)`

The latter would even allow /test-1.1_10/

