Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
6 ตอบกลับ
12841 มุมมอง

I'm reading the tutorials to develop the academy module. I have this controller:


from openerp import http
class Academy(http.Controller):
    @http.route('/academy/', auth='public', website=True)
    def index(self):
        Teachers = http.request.env['academy.teachers']
        return http.request.render('academy.index', {
            'teachers': Teachers.search([]),
        })
 @http.route('/academy/<model("academy.teachers"):teacher>/', auth='public', website=True)
 def teacher(self, teacher):
  return http.request.render('academy.biography', {
   'person': teacher
  })


The first routing for list of teachers works just fine but when I call second one, I get the 404-Not Found error message. When I seperate two routings by putting them in seperate files, both of them work perfectly. I want to put both of them in one single file, Am I missing something here?

 

อวตาร
ละทิ้ง

But the "Hello World" example appeared, earlier?

ผู้เขียน

Yes, why?

ผู้เขียน

You've got a problem with that?

คำตอบที่ดีที่สุด

check whether the name of method u you defined your route above is different or same.

there must define different method name for different route.

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Try to visit the link: localhost:8069/academy/your_teacher's_name-1

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Indentation of second @http.route is not correct. After modification don't forget to restart odoo service.

อวตาร
ละทิ้ง