# Set site index

**URL:** <https://forum.kirupa.com/t/set-site-index/261673>\
**Category:** programming\
**Created:** [May 29, 2008, 6:41pm UTC](https://forum.kirupa.com/t/set-site-index/261673 "2008-05-29T18:41:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![nobody](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@nobody](https://forum.kirupa.com/u/nobody)\
**Post date:** [May 29, 2008, 6:41pm UTC](https://forum.kirupa.com/t/set-site-index/261673/1 "2008-05-29T18:41:14Z")

</div>

So for the most part in Django I have no problem setting an app index. But what about the actual project, how do I set an index for that?

I’m probably not explaining myself well but if you go to [www.thisandco.com](http://www.thisandco.com) I get a routing error, I’m just curious how I would set it up to server a template.

---

<div class="post-metadata">

**Author:** ![andr\_in](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/andr_in/32/37_2.png) [@andr\_in](https://forum.kirupa.com/u/andr_in)\
**Post date:** [May 29, 2008, 7:17pm UTC](https://forum.kirupa.com/t/set-site-index/261673/2 "2008-05-29T19:17:46Z")

</div>

I’m not sure what you mean exactly but to get rid of the error you should have a regexp matching a blank url in you urls.py.  
e.g.  
(r’^$’, ‘somesite.someapp.views.index’) #or whatever view you’d like to serve as root

---

<div class="post-metadata">

**Author:** ![nobody](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@nobody](https://forum.kirupa.com/u/nobody)\
**Post date:** [May 29, 2008, 8:55pm UTC](https://forum.kirupa.com/t/set-site-index/261673/3 "2008-05-29T20:55:31Z")

</div>

Gotcha, so I have to have an app specifically for an index page?

The way I see it I have:  
project/app

So this translates to  
[site.com/app](http://site.com/app)

I can set an index to [site.com/app](http://site.com/app) with the view like you posted, but what about just setting the index for [site.com](http://site.com)?

---

<div class="post-metadata">

**Author:** ![andr\_in](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/andr_in/32/37_2.png) [@andr\_in](https://forum.kirupa.com/u/andr_in)\
**Post date:** [May 30, 2008, 11:37am UTC](https://forum.kirupa.com/t/set-site-index/261673/4 "2008-05-30T11:37:19Z")

</div>

hmm I never questioned the methods I’ve been using, but I’m pretty sure you need to have an app to serve content. So the index content for the page has to come from some kind of app.

So basically I think you need to have an urls.py in your project folder where you include other urls.py-s (from different app folders) and you just need to route the index page to some view in some app separately.

Not 100% sure here but that’s how I did it, which was a while ago…

---

<div class="post-metadata">

**Author:** ![nobody](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@nobody](https://forum.kirupa.com/u/nobody)\
**Post date:** [May 30, 2008, 5:42pm UTC](https://forum.kirupa.com/t/set-site-index/261673/5 "2008-05-30T17:42:56Z")

</div>

Yeah that sounds right. Hmmm. This stuff sure is confusing.

---

<div class="post-metadata">

**Author:** ![andr\_in](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/andr_in/32/37_2.png) [@andr\_in](https://forum.kirupa.com/u/andr_in)\
**Post date:** [May 31, 2008, 12:14pm UTC](https://forum.kirupa.com/t/set-site-index/261673/6 "2008-05-31T12:14:04Z")

</div>

Not really once you get the hang of it. Django is still the best framework I’ve ever used, and without a doubt it has the best uri routing system I’ve come across.  
But yeah this is coming from a guy who’s never touched ruby on rails, but django sure beats the hell out of all the php frameworks that follow the MVC pattern if you ask me.

---

<div class="post-metadata">

**Author:** ![nobody](https://avatars.discourse-cdn.com/v4/letter/n/94ad74/32.png) [@nobody](https://forum.kirupa.com/u/nobody)\
**Post date:** [June 2, 2008, 1:40am UTC](https://forum.kirupa.com/t/set-site-index/261673/7 "2008-06-02T01:40:29Z")

</div>

Well then I suppose i won’t give up.

Appreciate it, man =)

---

<div class="post-metadata">

**Author:** ![Jeff\_Wheeler](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@Jeff\_Wheeler](https://forum.kirupa.com/u/Jeff_Wheeler)\
**Post date:** [June 2, 2008, 2:16am UTC](https://forum.kirupa.com/t/set-site-index/261673/8 "2008-06-02T02:16:17Z")

</div>

You don’t need to create a separate app for the index. I find it usually feeds on content primarily from one section (e.g. blog), so it makes sense to have it be a generic view with a relevant [font=monospace]queryset[/font].

I tend to often just have a [font=monospace]direct\_to\_template[/font], though, because I don’t need anything complicated. I then just have a _index.html_ template that it uses.

You could also, of course, write a view outside of any app and just use that in your _urls.py_ file. Create a file _views.py_ (or whatever you want to call it) in the root of your project and write your view there; it’ll work just fine. 🙂
