I've been having a lot of trouble trying to clean up my URLs. If my app name is myapp, and I go out an buy the domain
myapp.com, when I deploy the site all the urls are going to read
www.myapp.com/myapp/default/function. How do I get rid of the app name and controller?
I've read the section in the book but did not find it very helpful. If I set
default_application = 'myapp' # ordinarily set in base routes.py
default_controller = 'default' # ordinarily set in app-specific routes.py
default_function = 'index' # ordinarily set in app-specific routes.py
This works for the index function, so if I go to my local server
127.0.0.1:8000 I will see the page from myapp/default/index. But if I add another page, for example myapp/default/contactus, I want to be able to just enter
127.0.0.1:8000/contactus instead of
127.0.0.1:8000/myapp/default/contactus.
I saw in another question someone posted an example using the parameter based system:
routers = dict(
# base router
BASE=dict(
default_application='myapp',
),
myapp=dict(
default_controller='default',
default_function='index',
functions=['index', 'contactus'],
),
)
where I guess you have to type in every function in the default controller? This still doesn't solve my problem. Using these settings does the same thing where going to
127.0.0.1:8000 will take you to
127.0.0.1:8000/myapp/default/index, but trying any other page like
127.0.0.1:8000/contactus does not work. I still need to use
127.0.0.1:8000/myapp/default/<function> for any additional pages I add.
The pattern based system seems a bit more confusing. Do people typically use this over the parameter one? Is the parameter one more of a crutch for new users? I tried adding to routes_in:
('/contactus', '/myapp/default/contactus'),
in hopes that using
127.0.0.1:8000/contactus would take me to 127.0.0.1:/8000/myapp/default/contactus, but this seems to have no effect. Are there better tutorials on how to use route_in/out? Will I have to add an entry to routes for every page I add, or are there shortcuts?
Thanks
*One side note, I saw routes.py needs to be reloaded every time it is changed, so I have been restarting the server when testing these examples.