56663

Python/django error: 'myapp' is not a registered namespace

Question:

I am facing a very unusual problem.

I've registered the namespace myapp using app_name in my main project's urls.py file like this:

app_name = 'myapp'

I'm writing a view where the user registers and is redirected to the homepage. However, when I'm using the redirect function in myapp's views.py file like this:

return redirect('myapp: index')

I'm getting the following error after clicking the registration form's submit button:

NoReverseMatch at / 'myapp' is not a registered namespace

I tired looking for a solution but to no avail. Help please :)

Answer1:

app_name = 'myapp'

is meant to be put <a href="https://docs.djangoproject.com/en/1.10/topics/http/urls/#url-namespaces-and-included-urlconfs" rel="nofollow">in an <em>included</em> urls.py</a>. It has no effect in a urls.py that is not included in another.

I recommend moving your URLs into the app and including them in your site's urls.py. Then your namespace should work.

Recommend

  • How get a focus element in QWebView/QWebPage?
  • How to create a custom source app for spring-cloud-stream-app-starters project
  • Why does Rust have both call by value and call by reference?
  • In x86 assembly, is it better to use two separate registers for imul?
  • MVC 3 - Editor template for List Model [closed]
  • Is there a way to focus on a dynamically created form on Angular 4/Ionic3?
  • yii2 create translated URLs
  • Git Configuration with eclipse--not able to push code from eclipse to remote git server
  • Open Graph Publish Using Spring Social
  • Index.php as custom error page
  • read values from form post in jquery or javascript
  • Azure table store snapshot/backup capability
  • How to make JSON.NET deserialize to Microsoft Date Time?
  • How to get current document uri in XSLT?
  • SharedPreferences or SQLite Database?
  • Sencha Touch 2.0 Controller refs attribute not working?
  • Typescript - Unable to get 'import' statement to function
  • Different response to non-authenticated users and AJAX calls
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Traverse Array and Display in markup
  • Cannot Parse HTML Data Using Android / JSOUP
  • NSLayoutConstraint that would pin a view to the bottom edge of a superview
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • coudnt use logback because of log4j
  • Getting Messege Twice Using IMvxMessenger
  • Authorize attributes not working in MVC 4
  • Django query for large number of relationships
  • Busy indicator not showing up in wpf window [duplicate]
  • Running Map reduces the dimensions of the matrices
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Reading document lines to the user (python)
  • Binding checkboxes to object values in AngularJs
  • How can I use `wmic` in a Windows PE script?
  • Python/Django TangoWithDjango Models and Databases
  • Net Present Value in Excel for Grouped Recurring CF
  • How to push additional view controllers onto NavigationController but keep the TabBar?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?