How can I set a flatpage to be my homepage?

325 views
Skip to first unread message

mongoose

unread,
Nov 21, 2010, 5:48:24 AM11/21/10
to Django users
Hi there,

I've created some flatpages and they work great. For example
http://127.0.0.1:8000/home/ and http://127.0.0.1:8000/blog/

I'm catching my flatpages with
urlpatterns += patterns('',
(r'', include('darren_web.flatpages.urls')),
)

What I want though is for http://127.0.0.1:8000/home/ to come up as
http://127.0.0.1:8000/
How can I do this?


Thanks

vikalp sahni

unread,
Nov 21, 2010, 1:32:12 PM11/21/10
to django...@googlegroups.com
Hi,

If i understood ur question properly

you need a URL rewrite. you can try either

Apache Rewrite (1st Preference) or 
you can also import a django app "django.contrib.redirects"

which will help u in redirecting URL's 

Regards
//Vikalp




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


Joseph (Driftwood Cove Designs)

unread,
Nov 21, 2010, 1:43:08 PM11/21/10
to Django users
mongoose -
all you need to do is specify the url: /
for the flatpage you want to be homepage.

a flatpage can only have one URL - if you want it to show up on 2
urls (e.g. / and /home/), you'll need a re-direct, a view, a re-write
rule, or some other trick.

good luck.

On Nov 21, 2:48 am, mongoose <darrenma1...@gmail.com> wrote:
> Hi there,
>
> I've created some flatpages and they work great. For examplehttp://127.0.0.1:8000/home/andhttp://127.0.0.1:8000/blog/
>
> I'm catching my flatpages with
> urlpatterns += patterns('',
>     (r'', include('darren_web.flatpages.urls')),
> )
>
> What I want though is forhttp://127.0.0.1:8000/home/to come up ashttp://127.0.0.1:8000/

mongoose

unread,
Nov 23, 2010, 9:35:58 AM11/23/10
to Django users
Hi There,

I've specified the URL as / in the admin.
Now I get an error from firefox telling me "The page isn't redirecting
properly".

This is what I'm using for the URLs.py
urlpatterns += patterns('',
(r'^$', include('django.contrib.flatpages.urls')),
)



On Nov 21, 8:43 pm, "Joseph (Driftwood Cove Designs)"
<powderfl...@gmail.com> wrote:
> mongoose -
>   all you need to do is specify the url:  /
>   for theflatpageyou want to be homepage.
>
>   aflatpagecan only have one URL - if you want it to show up on 2
> urls (e.g. / and /home/), you'll need a re-direct, a view, a re-write
> rule, or some other trick.
>
> good luck.
>
> On Nov 21, 2:48 am, mongoose <darrenma1...@gmail.com> wrote:
>
> > Hi there,
>
> > I've created some flatpages and they work great. For examplehttp://127.0.0.1:8000/home/andhttp://127.0.0.1:8000/blog/
>
> > I'm catching my flatpages with
> > urlpatterns += patterns('',
> >     (r'', include('darren_web.flatpages.urls')),
> > )
>
> > What I want though is forhttp://127.0.0.1:8000/home/tocome up ashttp://127.0.0.1:8000/

mongoose

unread,
Nov 24, 2010, 8:16:50 AM11/24/10
to Django users
I tried this approach

urlpatterns += patterns('',
(r'^$', 'django.views.generic.simple.direct_to_template',
{'template': 'flatpages/homepage.html'}),
)

Good news is it's loads the homepage.
Bad news is that it loads a blank page.
Other bad news is that now all the other flatpages don't load when I
put in their URL.

There is something very simple I'm just not getting isn't there?
> > > What I want though is forhttp://127.0.0.1:8000/home/tocomeup ashttp://127.0.0.1:8000/

mongoose

unread,
Nov 24, 2010, 8:23:53 AM11/24/10
to Django users
OK further updates.

I updated my URLs to have the following.
urlpatterns += patterns('',
(r'', 'django.views.generic.simple.direct_to_template', {'template':
'flatpages/default.html'}),
)

This now loads all my flatpages and has the deisred effect on the
homepage.
But still the pages that load are blank.

I've got
<h1>{{ flatpage.title }}</h1>
<p>{{ flatpage.content }}</p>

In my page but still just white.


Any suggestions?
> > > > What I want though is forhttp://127.0.0.1:8000/home/tocomeupashttp://127.0.0.1:8000/

Jason Mayfield

unread,
Nov 24, 2010, 8:32:25 AM11/24/10
to django...@googlegroups.com
Is there a reason you are adding the flatpages to your urls.py rather than using the FlatpageFallbackMiddleware, as specified in the docs?

http://docs.djangoproject.com/en/1.2/ref/contrib/flatpages/#installation

> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
>

- Jason

mongoose

unread,
Nov 24, 2010, 8:41:50 AM11/24/10
to Django users
Hi Jason,

That fixed everything.



Thanks
Reply all
Reply to author
Forward
0 new messages