Skip to content Skip to sidebar Skip to footer

Django: Noreversematch At / 'myapp' Is Not A Registered Namespace

I have this error during template rendering. What i'm trying to do is allow the user to upload a csv then process the data into models. error at line 109 'myapp' is not a registere

Solution 1:

try this urls.py in mysite

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url(r'^', include('anomaly.urls',namespace='anomaly'))

To qualify a url name with a namespace use the syntax 'namespace:name'

<form action="{% url 'anomaly:upload_csv' %}" method="POST" enctype="multipart/form-data"class="form-horizontal"> 

Solution 2:

It seems that you have switched to Django 2.0 This is one of the change the new version of Django contains. Go to urls.py of your app anomaly and add the app_name = "anomaly". So your urls.py file will be like

    app_name = "anomaly"

    urlpatterns = [
    url(r'^$', views.post_list, name='post_list'),
    url(r'^upload/csv/$', views.upload_csv, name='upload_csv'),
]

Solution 3:

Your app name is anomaly. You should write this like this

<form action="{% url "anomaly:upload_csv" %}" method="POST" enctype="multipart/form-data"class="form-horizontal"> 

Solution 4:

I have encountered this quite a few times when upgrading sites to the latest version of Django.

Creating a new app will create a file called apps.py which would look something like this:

from django.apps import AppConfig

    classMyappConfig(AppConfig):
        name = 'myapp'

I would usually add this file to all apps in a project that is being updated. Replace with the name of the app, then add this app_name = MyappConfig.name to the urls.py for the app.

You can find out more information about Configuring Application here in the Django Docs

Post a Comment for "Django: Noreversematch At / 'myapp' Is Not A Registered Namespace"