Wow, thanks for the help! I do understand the principle of views and
templates now, but I still need some help.

I have managed to get out the slug name of my projects in
"mydomain/portfolio/". But I don't know how I write the view for the
detail page or how I get the right URL to the detail.

I want the URL to be "mydomain/portfolio/category_slug/project_slug"
like "mydomain/portfolio/3d/house/".

My urls.py looks like this:

from django.conf.urls.defaults import *
from myproject.portfolio.models import Project
from myproject.portfolio.models import Category

urlpatterns = patterns('',
    # Polls:
    (r'^polls/$', 'myproject.polls.views.index'),
    (r'^polls/(?P<poll_id>\d+)/$', 'myproject.polls.views.detail'),
    (r'^polls/(?P<poll_id>\d+)/results/$',
'myproject.polls.views.results'),
    (r'^polls/(?P<poll_id>\d+)/vote/$', 'myproject.polls.views.vote'),

        # Portfolio:
    (r'^portfolio/$', 'myproject.portfolio.views.index'),
        (r'^portfolio/(?P<categoy_slug>\d+)/$',
'myproject.portfolio.views.list'),
    (r'^portfolio/(?P<categoy_slug>\d+)/(?P<project_slug>\d+)/$',
'myproject.portfolio.views.detail'),


    # For homepage:
    (r'^$', 'django.views.generic.simple.direct_to_template',
{'template': 'homepage.html'}),

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


My portfolio/view.py looks like this:

from django.shortcuts import render_to_response

from myproject.portfolio.models import Project
from myproject.portfolio.models import Category

# Create your views here.
def index(request):
    latest_project_list = Project.objects.all().order_by('-created')
    return render_to_response('portfolio/index.html',
{'latest_project_list': latest_project_list})


my portfolio/index.html looks like this:

<h2>Projects</h2>

{% if latest_project_list %}
    <ul>
    {% for project in latest_project_list %}
        <li><a href="{{ category.slug }}/{{ project.slug }}">{{
project.title }}</a></li>
    {% endfor %}
    </ul>
{% else %}
    <p>No Projects are available.</p>
{% endif %}


I don't think my urls.py is correct for this type of setup, but Im not
shure. Would really appreciate all the help I can get. And thank you
again Malcom for all your help!

My portfolio app is still missing from the main menu inside admin, but
still works if I type in the direct url to it.
"mydomain/admin/portfolio/project/" . If anyone could spot the error in
my model.py (posted in the first post)  that is causing the portfolio
to disappear, please let me know!


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to