Hi Kenneth, Thanks for your suggestion. I will look at the link you gave for details. BTW, why I wanna customize is I got some special requirements from customer. Anyway, I will follow your suggestion that don't break those existing behavior in Mezzanine unless I am sure it's an improvement.
Thanks again. Wesley Hi Wesley, > > What Stephen is saying is that the default settings.DEVICE_USER_AGENTS > provides a better mapping than the one you hacked together. Take a look at > https://github.com/stephenmcd/mezzanine/blob/e2b0aa6d6fbf699f3e1c68a4a522f5abaf40bbb6/mezzanine/core/defaults.py#L116-L136 > > to see how Mezzanine behaves out-of-the-box. Putting your own > tuple-of-tuples in there is begging for breakage. > > Looking back at the history of your posts to this list, I notice lots of > attempts by you to go your own way. While you may get to your destination, > you are spending a lot of energy fighting the sane defaults and well-tested > functionality of Mezzanine. It appears, to this reader, that you think your > cases are special and require lots of customizing. Twenty years in this > business has taught me that there are very few special cases and almost all > of those should be put on the back burner and re-considered when time > allows. Take some time to internalize the Zen of Python > <http://legacy.python.org/dev/peps/pep-0020/>. Resist the temptation to > make changes until you can prove that the change will be an improvement. > > hth, > ken > > On Sun, Sep 28, 2014 at 6:40 AM, Wesley <[email protected] <javascript:>> > wrote: > >> Hi Stephen, >> Do you mean remove the whole DEVICE_USER_AGENTS? >> Then that will act just as usual, how to trigger action as I wanted? >> >> Thanks. >> Wesley >> >> >> >>> On Sun, Sep 28, 2014 at 7:48 PM, Wesley <[email protected]> wrote: >>> >>>> Hi guys, >>>> I have a question about displaying pages according to user agent. >>>> Currently I wanna display menus only when requests from PC browser, >>>> i.e. when receive request from cell phone browser,hide the page menus. >>>> >>>> 1. I set the following in settings.py >>>> DEVICE_USER_AGENTS = ( >>>> ("mobile", ("Android", "BlackBerry", "iPhone")), >>>> ("desktop", ("Windows", "Macintosh", "Linux")), >>>> ) >>>> DEVICE_DEFAULT = "desktop" >>>> >>>> 2. I add mytheme(my own app used to customize >>>> mezzanine)/templates/mobile/base.html, and write some simple words in >>>> base.html. >>>> >>>> Then, run server again, access from PC chrome, it's OK as usual. >>>> But access from my nexus chrome, pages are some as previous. >>>> This is user agent I print: >>>> * PC chrome is Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 >>>> (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36 >>>> * Nexus phone chrome is Mozilla/5.0 (Linux; Android 4.4.4; Nexus 4 >>>> Build/KTU84P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.99 >>>> Mobile Safari/537.36 >>>> >>>> So, seems mezzanine didn't prefix template path with mobile, is there >>>> anything else I should configure or do? >>>> >>>> Thanks. >>>> Wesley >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Mezzanine Users" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to [email protected]. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> Your phone's user agent also says it's Linux which might cause the >>> behaviour. >>> >>> Try removing those settings you defined, the default for DEVICE_USER_AGENTS >>> already contains a much more comprehensive list of mobile user agents, and >>> doesn't define any for the desktop, since it's the default already. >>> >>> >>> -- >>> Stephen McDonald >>> http://jupo.org >>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Mezzanine Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Mezzanine Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
