Serving Static Information

11 views
Skip to first unread message

newbie730

unread,
Oct 29, 2008, 8:17:53 PM10/29/08
to Satchmo users
I'm working toward having a fully integrated shopping/browsing system
that shows a seamless shopping experience while also displaying static
content.

The static content will be sections such as:

Splash Page
About Us
Contact

How can I configure my store to be able to serve this type of
content? Do I need to create special templates to handle these cases?

David Lindquist

unread,
Oct 29, 2008, 8:24:40 PM10/29/08
to satchm...@googlegroups.com
Check out the Flatpages app that comes with Django:

http://docs.djangoproject.com/en/dev/ref/contrib/flatpages/

john

unread,
Oct 30, 2008, 3:01:27 PM10/30/08
to Satchmo users
If you use the flatpages app make sure you add your flatpages
urlpattern into ./satchmo/shop/urls.py in order to get it to match
correctly....

cheers,
Stjohn

john

unread,
Oct 30, 2008, 3:22:35 PM10/30/08
to Satchmo users
Hmm.... that doesn't work properly.

What is the correct way to set up urls when you add flatpages? If you
add the flatpage urlpattern match to the end of ./shop/urls.py you can
no longer view products if you use the base_index.html template as
products are not contained within that shop/url.py so of course it
doesn't find a match before hitting the flatpage include....

many thanks for any help,
Stjohn

Bruce Kroeze

unread,
Oct 30, 2008, 9:18:16 PM10/30/08
to satchm...@googlegroups.com
On Thu, Oct 30, 2008 at 12:22 PM, john <stj...@kid-safe.co.uk> wrote:

Hmm....  that doesn't work properly.

What is the correct way to set up urls when you add flatpages? If you
add the flatpage urlpattern match to the end of ./shop/urls.py you can
no longer view products if you use the base_index.html template as
products are not contained within that shop/url.py so of course it
doesn't find a match before hitting the flatpage include....

many thanks for any help,
Stjohn

First, don't ever modify shop/urls.py.  That means you are forking the code, and you won't get updates properly.  I guarantee you will regret it if you fork the code.

Instead, use the SHOP_URLS facility in your settings file. That's what it is for.  For more customized needs, please refer to my blog article about setting up a flexible, maintainable site.  I talk about URLs there.


For you, I recommend you simply directly reference the urls that you want to serve.  Something like this:

urlpatterns += patterns('',
    ('^terms/', 'django.views.generic.simple.direct_to_template', 
        {'template' : 'site/terms.html'}, 'shop_terms'))

If you really want to use flatpages, then just have it be active for urls under some known prefix, like so:

urlpatterns += patterns('',
    ('^pages/', include('django.contrib.flatpages.urls')))

Bruce Kroeze

john

unread,
Oct 31, 2008, 4:41:35 PM10/31/08
to Satchmo users
Hi Bruce,
excellent advice. I will follow it, many thanks. I added the relevant
urlpatterns as you described to ./mystore/urls.py and created the
necessary html files which worked great. I tested out your flatpage
urlpattern in the same way and that also works great.

I am not sure what you mean by 'use the SHOP_URLS pattern in your
settings file' - should the above patterns go into my ./mystore/
settings.py and not ./mystore/urls.py?

With reference to your 'starting a new store real world project
layout' I was able to follow all the great advice apart from the 'url
layout' part and the 'install the site app'. I now understand what you
are saying but I think you might have made a couple of small mistakes
(of course I could easily be misunderstanding!).

You say to set:
ROOTURL_CONF = storename.site.urls

but when you describe the project setup you do not say to create the
file ./storename/site/urls.py As I understand it now you are saying
that you can use ./storename/site/urls.py to import the satchmo.urls
file and then make any custom changes there which seems like a great
idea. Is the 'install the site app' part of the article a pre-
requisite to setting up the custom urls.py as described above? As far
as I understand it would seem like the answer is yes, if so would it
not be better to put this part first?

When I follow your article exactly it does not work. When understand
what you are trying to tell us and make a couple of small changes I
can get most of it to work. I really appreciate your advice but as a
beginner with django/python satchmo it can be tricky! Could you
describe further about setting up the custom app?

Looking forward to receiving more of your great advice and tips! -
sorry if it is my misunderstanding.

best regards,

Bruce Kroeze

unread,
Oct 31, 2008, 4:56:46 PM10/31/08
to satchm...@googlegroups.com
On Fri, Oct 31, 2008 at 1:41 PM, john <stj...@kid-safe.co.uk> wrote:

Hi Bruce,
excellent advice. I will follow it, many thanks. I added the relevant
urlpatterns as you described to ./mystore/urls.py and created the
necessary html files which worked great. I tested out your flatpage
urlpattern in the same way and that also works great.

I am not sure what you mean by 'use the SHOP_URLS pattern in your
settings file' - should the above patterns go into my ./mystore/
settings.py and not ./mystore/urls.py?

Ah, it was a "do this OR that" set of instructions.  If you are setting things up according to my article, no need to use SHOP_URLS.
 

With reference to your 'starting a new store real world project
layout' I was able to follow all the great advice apart from the 'url
layout' part and the 'install the site app'. I now understand what you
are saying but I think you might have made a couple of small mistakes
(of course I could easily be misunderstanding!).

Thanks for the feedback.  You seem to have gotten the gist of what I was telling you to do.  Yes, you need to install a "site" app, and then use the urls.py file from there.  I'll go through my article again and try to streamline the order of the steps.  Writing tutorials is much trickier than simple coder-docs!
 
--
Bruce Kroeze

john

unread,
Nov 1, 2008, 12:31:45 PM11/1/08
to Satchmo users
> Ah, it was a "do this OR that" set of instructions.  If you are setting
> things up according to my article, no need to use SHOP_URLS.
>
> > With reference to your 'starting a new store real world project
> > layout' I was able to follow all the great advice apart from the 'url
> > layout' part and the 'install the site app'. I now understand what you
> > are saying but I think you might have made a couple of small mistakes
> > (of course I could easily be misunderstanding!).
>
> Thanks for the feedback.  You seem to have gotten the gist of what I was
> telling you to do.  Yes, you need to install a "site" app, and then use the
> urls.py file from there.  I'll go through my article again and try to
> streamline the order of the steps.  Writing tutorials is much trickier than
> simple coder-docs!
>
> --

Hi Bruce,
many thanks, I get the idea now. I really appreciate your articles
they are a great help to get started. Please keep writing more! If you
get the chance and could try and streamline the order of steps that
would be really cool.

best regards,
Stjohn

Shankar Dhanasekaran

unread,
Dec 6, 2008, 2:58:28 PM12/6/08
to satchm...@googlegroups.com
Hi Bruce,
I created a project as outlined in your blog post. It works very well but I couldnt understand the uses of different folders, except for the templates folder. Please can you explain why I would need these folders (marked in yellow, the who /etc folder with all its content) and how I can use them as intended?

storename/
__init__.py
local_settings.py
manage.py
settings.py
bin/
(here are various scripts you may use for testing or whatever)
etc/
init.d/
storename
sysconfig/
storename
fixtures/
site/
__init__.py
models.py
templatetags/
__init__.py
static/
css/
images/
js/
templates/
storename/



Thanks so much,

Shakthi

Bruce Kroeze

unread,
Dec 6, 2008, 3:09:11 PM12/6/08
to satchm...@googlegroups.com
On Sat, Dec 6, 2008 at 11:58 AM, Shankar Dhanasekaran <newage....@gmail.com> wrote:
Hi Bruce,
I created a project as outlined in your blog post. It works very well but I couldnt understand the uses of different folders, except for the templates folder. Please can you explain why I would need these folders (marked in yellow, the who /etc folder with all its content) and how I can use them as intended?

storename/
__init__.py
local_settings.py
manage.py
settings.py
bin/
(here are various scripts you may use for testing or whatever)
etc/
init.d/
storename
sysconfig/
storename

When you roll out the live site, you will need an init script to put in /etc/init.d so that the store can auto-start, reboot, etc.

I prefer to keep those files under version control in my site directory and then symlink them into place on the server.  My standard /etc/init.d/storename script refers to variables it expects to find at /etc/sysconfig/storename.

Make sense?

---
Bruce Kroeze

 

Shankar Dhanasekaran

unread,
Dec 7, 2008, 1:35:28 AM12/7/08
to satchm...@googlegroups.com
Thanks Bruce. I understand a bit. Can you please give an example of the script that you'd use in init.d? I am not so expert like in satchmo and maybe with an example I can understand.

Thanks,
Shakthi

Bruce Kroeze

unread,
Dec 7, 2008, 4:02:29 PM12/7/08
to satchm...@googlegroups.com
Here you go, I wrote a quick article, including my init scripts for redhat or debian style servers.

--
Bruce Kroeze
http://solidsitesolutions.com
Dynamic Designs, Optimized

Shankar Dhanasekaran

unread,
Dec 7, 2008, 7:45:38 PM12/7/08
to satchm...@googlegroups.com
Thank you so much Bruce. It greatly helps to understand. BTW, what do you suggest as the best for source control system in your experience?

Thanks,
Shakthi

Bruce Kroeze

unread,
Dec 7, 2008, 9:09:33 PM12/7/08
to satchm...@googlegroups.com
I heartily recommend Mercurial, hosted on http://www.assembla.com, that's what I use for all my clients (where I have a choice, anyway), my open source projects, and my private projects.

I have also heard great things about Mercurial on http://bitbucket.org
Reply all
Reply to author
Forward
0 new messages