1

I configured my $routeProvider like this:

angular.module('autotestApp').config(['$routeProvider', '$locationProvider', function ($routeProvider, $locationProvider){

$locationProvider.html5Mode(true);

$routeProvider
    .when('/store', {
        templateUrl: 'store.html',
        controller: 'StoreController'
    })
    .when('/groups', {
        templateUrl: 'groups.html',
        controller: 'GroupsController'
    })
    .when('/purchases', {
        templateUrl: 'purchases.html',
        controller: 'PurchaseController'
    })
    .when('/settings', {
        templateUrl: 'settings.html',
        controller: 'SettingsController'
    })
    .otherwise({redirectTo: '/store'});

}]);

and I have the following links:

<ul>
    <li><a href="store">Stores</a></li>
    <li><a href="groups">Groups</a></li>
    <li><a href="purchases">Purchases</a></li>
    <li><a href="settings">Settings</a></li>
</ul>

when I click these links, it is working fine but when I manually type in the browser or when I refresh the page, I get "page not found" error

UPDATE:

This is my urls.py:

urlpatterns = patterns(
    '',

    url(r'^login', login_user, name='login'),
    url(r'^logout', logout_user, name='logout'),
    url(r'^register', register_user, name='register'),
    url(r'^settings', user_settings, name='settings'),
    url(r'^reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>.+)/$',
        reset_confirm, name='reset_confirm'),
    url(r'^reset/$', reset, name='reset'),

    url(r'^purchases', purchases, name='purchases'),
    url(r'^_store', _store, name='_store'),

    # payment
    url(r'^payment/billing/(?P<vouchers_package_id>[0-9]+)$', billing_info,
        name='billing'),
    url(r'^payment/success', payment_success, name='payment_success'),

    # vouchers
    url(r'^vouchers/send_to_group/(?P<group_id>[0-9]+)',
        send_vouchers_to_group, name='send_vouchers_to_group'),
    url(r'^vouchers/send', send_voucher, name='send_voucher'),

    # students in groups
    url(r'^groups/students/delete/(?P<group_student_id>[0-9]+)',
        delete_student, name='delete_student'),
    url(r'^groups/students/(?P<student_id>[0-9]+)', students,
        name='student_detail'),
    url(r'^groups/students', students, name='students'),

    # groups
    url(r'^groups/delete/(?P<group_id>[0-9]+)', delete_group,
        name='delete_group'),
    url(r'^groups/(?P<group_id>[0-9]+)', groups, name='group_detail'),
    url(r'^groups', groups, name='groups'),
    url(r'^$', dashboard_page, name='dashboard'),
)

How to fix this?

Rodrigue
  • 169
  • 13

1 Answers1

0

you have to add a catch all route in your url.py or so

url(r'^', TemplateView.as_view(template_name='index.html'))

please note, this rule has to be the last in the list, because its a catch all route, everything that doesn't match gets handled by this one.

Raphael Müller
  • 2,180
  • 2
  • 15
  • 20
  • I updated my question to include urls.py. Can you take a look at it please? I put the catch all route the last. But it did not help :( – Rodrigue Dec 04 '14 at 09:48
  • as example we take a look at `settings`. if you take a closer look there, you'll notice, that it's already defined as a route. therefor. your catch all won't kick in and the view defined in your route takes place. while angular only needs "one view" on the server, it handles the separate views itself. – Raphael Müller Dec 04 '14 at 10:20