I thought I could link two apps together however I can't seem to get
this working.

I have 2 very very basic apps (news, events)

And i would like to display them both on a homepage as sort of widgets
(just showing latest 5 of each)

I have a events.html template:
[code]
<h2>5 Upcoming Events</h2>
<ul>
{% if latest_events_list %}

  {% for events in latest_events_list %}

  <li><b>{{ events.eventTitle }}</b><br />Date: {{ events.date|date:"d/
m/y" }}<br />Location: {{ events.location }}
    <br />
    Start time: {{ events.startTime|time:"P" }} </li>
    Details: {{ events.description }}

  {% endfor %}
    </ul>
{% else %}
  No events planned.
  {% endif %}

                </div>

                <p>&nbsp;</p>
</div>
        <div id="object">Sakushi News</div>
                <div id="horimenu">

                </div>


                </span></div>
                <div id="content">
<h2>5 Latest News Articles</h2>
<ul>
{% if latest_news %}

  {% for news in latest_news_list %}
  {{ news.newsTitle }}
  <li><br />Date: {{ news.date|date:"d/m/y" }}<br />Author:
{{ news.author }}
    <br />
    {{ news.newsArticle }} </li>

  {% endfor %}
    </ul>
{% else %}
  No news articles at present.
  {% endif %}
[/code]

This code shows the last 5 events, but does not show any news items.

My urls.py is:
[code]
from django.conf.urls.defaults import *
from sakushi.events.models import Event

urlpatterns = patterns('',
    (r'^test/', 'sakushi.events.views.events'),

    # Uncomment this for admin:
     (r'^admin/', include('django.contrib.admin.urls')),
)
[/code]

My events.views:
[code]
from sakushi.events.models import Event
from sakushi.news.models import News
from django.shortcuts import get_object_or_404, render_to_response
from django.http import HttpResponseRedirect

def events(request):
  latest_events_list = Event.objects.all().order_by('date')[:5]
  return render_to_response('events.html', {'latest_events_list':
latest_events_list})

def news(request):
  latest_news_list = News.objects.all().order_by('date')[:5]
  return render_to_response('events.html', {'latest_news_list':
latest_news_list})

[/code]

I'm sure there is something wrong with my logic somewhere but I would
appreciate any help.

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

Reply via email to