title: How to block selected characters in simple register Django
body: <p>I have a problem  with simple registration in Django. When the user will write  at the first registration the username with '.' or @, for example 'User.Name' my internet application returns error like this 'NoReverseMatch at /'</p>
  
  <pre><code>Environment:
  
  
  Request Method: GET
  Request URL: http://127.0.0.1:8000/
  
  Django Version: 2.0.7
  Python Version: 3.7.0
  Installed Applications:
  ['django.contrib.admin',
   'django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'bootstrap3',
   'reviews',
   'registration']
  Installed Middleware:
  ['django.middleware.security.SecurityMiddleware',
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.middleware.common.CommonMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware',
   'django.middleware.clickjacking.XFrameOptionsMiddleware']
  
  
  Template error:
  In template C:\Users\tymot\Desktop\projrkt22.08-20.00\env\my_app\winerama\templates\base.html, error at line 50
     Reverse for 'user_review_list' with arguments '('aleksandra.franiczek',)' not found. 2 pattern(s) tried: ['review/user/$', 'review/user/(?P&lt;username&gt;\\w+)/$']
     40 :               &lt;/div&gt;
     41 :               &lt;div class="col-sm-4 offset-md-1 py-4"&gt;
     42 :                 &lt;h4 class="text-white"&gt;Nawigacja&lt;/h4&gt;
     43 :                 &lt;ul class="list-unstyled"&gt;
     44 :                   &lt;li&gt;&lt;a href="{% url 'reviews:home' %}" class="text-white"&gt;Strona główna&lt;/a&gt;&lt;/li&gt;
     45 :                   &lt;li&gt;&lt;a href="{% url 'reviews:wine_list' %}" class="text-white"&gt;Lista produktów&lt;/a&gt;&lt;/li&gt;
     46 :                   &lt;li&gt;&lt;a href="{% url 'reviews:review_list' %}" class="text-white"&gt;Najnowsze opinie&lt;/a&gt;&lt;/li&gt;
     47 :                 &lt;/ul&gt;
     48 :                 &lt;ul class="list-unstyled"&gt;
     49 :                   {% if user.is_authenticated %}
     50 :                   &lt;li&gt;&lt;a href=" {% url 'reviews:user_review_list' user.username %} " class="text-white"&gt;Witaj {{ user.username }}&lt;/a&gt;&lt;/li&gt;
     51 :                   &lt;li&gt;&lt;a href="{% url 'reviews:user_recommendation_list' %}" class="text-white"&gt;Sugerowane produkty&lt;/a&gt;&lt;/li&gt;
     52 :                   &lt;li&gt;&lt;a href="{% url 'logout' %}" class="text-white"&gt;Wyloguj&lt;/a&gt;&lt;/li&gt;
     53 :                   {% else %}
     54 :                   &lt;li&gt;&lt;a href="{% url 'login' %}" class="text-white"&gt;Logowanie&lt;/a&gt;&lt;/li&gt;
     55 :                   &lt;li&gt;&lt;a href="/accounts/register" class="text-white"&gt;Rejestracja&lt;/a&gt;&lt;/li&gt;
     56 :                   {% endif %}
     57 :                 &lt;/ul&gt;
     58 :               &lt;/div&gt;
     59 :             &lt;/div&gt;
     60 :           &lt;/div&gt;
  
  
  Traceback:
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\exception.py" in inner
    35.             response = get_response(request)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response
    128.                 response = self.process_exception_by_middleware(e, request)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\handlers\base.py" in _get_response
    126.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)
  
  File "C:\Users\tymot\Desktop\projrkt22.08-20.00\env\my_app\winerama\reviews\views.py" in review_list
    13.     return render(request, 'reviews/review_list.html', context)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\shortcuts.py" in render
    36.     content = loader.render_to_string(template_name, context, request, using=using)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loader.py" in render_to_string
    62.     return template.render(context, request)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\backends\django.py" in render
    61.             return self.template.render(context)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in render
    175.                     return self._render(context)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in _render
    167.         return self.nodelist.render(context)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in render
    943.                 bit = node.render_annotated(context)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in render_annotated
    910.             return self.render(context)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\loader_tags.py" in render
    155.             return compiled_parent._render(context)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in _render
    167.         return self.nodelist.render(context)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in render
    943.                 bit = node.render_annotated(context)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in render_annotated
    910.             return self.render(context)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\defaulttags.py" in render
    314.                 return nodelist.render(context)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in render
    943.                 bit = node.render_annotated(context)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\base.py" in render_annotated
    910.             return self.render(context)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\template\defaulttags.py" in render
    447.             url = reverse(view_name, args=args, kwargs=kwargs, current_app=current_app)
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\urls\base.py" in reverse
    90.     return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs))
  
  File "C:\Users\tymot\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\urls\resolvers.py" in _reverse_with_prefix
    636.         raise NoReverseMatch(msg)
  
  Exception Type: NoReverseMatch at /
  Exception Value: Reverse for 'user_review_list' with arguments '('aleksandra.franiczek',)' not found. 2 pattern(s) tried: ['review/user/$', 'review/user/(?P&lt;username&gt;\\w+)/$']
  </code></pre>
  
  <p>when the user will be removed from the database in django admin everything works well. 
  How can I block use of these marks upon first registration (in my situation)?</p>
  
  <p><strong>my file_registration.html looks like this</strong></p>
  
  <pre><code>{% block content %}
  &lt;div class="container marketing"&gt;
      &lt;form method="post" class="form"&gt;
          {% csrf_token %}
          {% bootstrap_form form layout='inline' %}
          {% buttons %}
          &lt;button type="submit" class="btn btn-primary"&gt;
            {% bootstrap_icon "user" %} Register
          &lt;/button&gt;
          {% endbuttons %}
      &lt;/form&gt;
  {% endblock %}
  </code></pre>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>urlpatterns = [
      path('', include('reviews.urls', namespace="reviews")),
      path('reviews/', include('reviews.urls', namespace="reviews")),
      path('admin/', admin.site.urls),
      path('accounts/', include('registration.backends.simple.urls')),
      path('accounts/', include('django.contrib.auth.urls')),
  ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  </code></pre>
  
  <p><strong>settings.py</strong></p>
  
  <pre><code>DEBUG = True
  
  ALLOWED_HOSTS = []
  
  
  # Application definition
  
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
      'bootstrap3',
      'reviews',
      'registration'
  ]
  
  ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window
  REGISTRATION_AUTO_LOGIN = True # Automatically log the user in.
  
  
  
  MIDDLEWARE = [
      'django.middleware.security.SecurityMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.common.CommonMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
  ]
  
  ROOT_URLCONF = 'winerama.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [os.path.join(BASE_DIR, 'templates')],
          'APP_DIRS': True,
          'OPTIONS': {
              'context_processors': [
                  'django.template.context_processors.debug',
                  'django.template.context_processors.request',
                  'django.contrib.auth.context_processors.auth',
                  'django.contrib.messages.context_processors.messages',
              ],
          },
      },
  ]
  
  WSGI_APPLICATION = 'winerama.wsgi.application'
  
  LOGIN_REDIRECT_URL = '/reviews/review/user'
  
  
  # Database
  # https://docs.djangoproject.com/en/2.0/ref/settings/#databases
  
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.sqlite3',
          'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
      }
  }
  
  
  # Password validation
  # https://docs.djangoproject.com/en/2.0/ref/settings/#auth-password-validators
  
  AUTH_PASSWORD_VALIDATORS = [
      {
          'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
      },
  ]
  
  
  # Internationalization
  # https://docs.djangoproject.com/en/2.0/topics/i18n/
  
  LANGUAGE_CODE = 'en-us'
  
  TIME_ZONE = 'UTC'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = False
  
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/2.0/howto/static-files/
  
  STATIC_URL = '/static/'
  
  MEDIA_URL = '/media/'
  MEDIA_ROOT = os.path.join(BASE_DIR, 'reviews/media')
  </code></pre>
  
  <p><strong>urls.py app</strong></p>
  
  <pre><code>from django.conf.urls import url
  
  from .import views
  
  app_name = 'reviews'
  
  urlpatterns = [
      # ex: /
      url(r'^$', views.review_list, name='review_list'),
      #Home
      url(r'^home/', views.frond_photo_list, name='home'),
      #Blog
      url(r'^blog/', views.blog_list, name='blog'),
      # ex: /review/5/
      url(r'^review/(?P&lt;review_id&gt;[0-9]+)/$', views.review_detail, name='review_detail'),
      # ex: /wine/
      url(r'^wine$', views.wine_list, name='wine_list'),
      # ex: /wine/5/
      url(r'^wine/(?P&lt;wine_id&gt;[0-9]+)/$', views.wine_detail, name='wine_detail'),
      url(r'^wine/(?P&lt;wine_id&gt;[0-9]+)/add_review/$', views.add_review, name='add_review'),
      url(r'^review/user/(?P&lt;username&gt;\w+)/$', views.user_review_list, name='user_review_list'),
      url(r'^review/user/$', views.user_review_list, name='user_review_list'),
      # ex: /recommendation - get wine recommendations for the logged user
      url(r'^recommendation/$', views.user_recommendation_list, name='user_recommendation_list'),
  </code></pre>
  
  <p>Any help will be appreciated. </p>