Monday, October 31, 2011

Re: Django Standalone Template

Try putting a comma at the end of the TEMPLATE_DIRS line.

Parentheses do not the tuple make. It's the comma. An expression
surrounded by parentheses is just the expression, so you're trying to
use each letter of your setting as a directory, I believe.

I take it you're not using the app directories loader?

On Mon, Oct 31, 2011 at 3:58 PM, Stefan Lisowski <s.lisowski@isti.com> wrote:
> On 10/31/2011 2:49 PM, Bill Freeman wrote:
>> I think that you have too many "admin"s.  Try:
>>
>>
>> TEMPLATE_DIRS=('C:/Python26/Lib/site-packages/django/contrib/admin/templates')
>
> Thanks for the suggestion. I don't see much difference on my system here
> though...
>
> C:\Program Files (x86)\Microsoft Visual Studio 8\VC>c:\Python26\python.exe
> Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)]
> on
> win32
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import django.template
>>>>
>>>> django.conf.settings.configure(TEMPLATE_DIRS=('C:/Python26/Lib/site-packages/django/contrib/admin/templates'),TEMPLATE_DEBUG=True,
>>>> DEBUG=True)
>>>> import django.template.loader as loader
>>>> loader.get_template("base.html")
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "c:\Python26\lib\site-packages\django\template\loader.py", line 157,
> in get_template
>    template, origin = find_template(template_name)
>  File "c:\Python26\lib\site-packages\django\template\loader.py", line 138,
> in find_template
>    raise TemplateDoesNotExist(name)
> django.template.base.TemplateDoesNotExist: base.html
>>>> loader.get_template("admin/base.html")
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "c:\Python26\lib\site-packages\django\template\loader.py", line 157,
> in get_template
>    template, origin = find_template(template_name)
>  File "c:\Python26\lib\site-packages\django\template\loader.py", line 138,
> in find_template
>    raise TemplateDoesNotExist(name)
> django.template.base.TemplateDoesNotExist: admin/base.html
>
> Has anyone here used the template system successfully without using all of
> Django?
>
>>
>> On Mon, Oct 31, 2011 at 3:30 PM, Stefan Lisowski<s.lisowski@isti.com>
>>  wrote:
>>>
>>> I appreciate the reply SmileyChris -
>>>
>>> On 10/30/2011 12:41 PM, SmileyChris wrote:
>>>>
>>>> Take a read through this section of the docs:
>>>>
>>>> https://docs.djangoproject.com/en/1.3/ref/templates/api/#loading-templates
>>>
>>> Yes, that's what I was reading.
>>>
>>>> Specifically, those templates are found via the app_directories.Loader.
>>>> So you'd run loader.get_template('admin/base.html') to get that
>>>> template. The reason that it's in a subdirectory is to avoid conflicts
>>>> with other applications (since they may want to use their own
>>>> 'base.html' template.
>>>
>>> So, my setting TEMPLATE_DIRS here to the actual subdirectory would not
>>> work?
>>>
>>>
>>> TEMPLATE_DIRS=('C:/Python26/Lib/site-packages/django/contrib/admin/templates/admin')
>>>
>>> I used this as an example to point to some templates that are known to
>>> work,
>>> rather than point to my own templates that don't work either. If I go
>>> into
>>> the Django code and print out the directory that's being searched, I see
>>> the
>>> correct directory there, so I don't know why things are failing. Maybe
>>> I'm
>>> just not instantiating things correctly?
>>>
>>> In any case, I tried your suggestion, but still no luck:
>>>
>>>>>> loader.get_template('admin/base.html')
>>>
>>> Traceback (most recent call last):
>>>  File "<stdin>", line 1, in<module>
>>>  File "django/template/loader.py", line 164, in get_template
>>>    template, origin = find_template(template_name)
>>>  File "django/template/loader.py", line 145, in find_template
>>>    raise TemplateDoesNotExist(name)
>>> django.template.base.TemplateDoesNotExist: admin/base.html
>>>
>>> (I also tried without manually setting TEMPLATE_DIRS, but just ran
>>> django.conf.settings.configure(), still to no avail.)
>>>
>>> Anyone, any ideas? I'm completely new to Django, but I've not been
>>> working
>>> in Python lately either, so it could just be a Python mistake on my part.
>>>
>>> - Stefan
>>>
>>> -------- Original Message --------
>>> Subject: Django Standalone Template
>>> Date: Fri, 28 Oct 2011 19:54:20 -0700 (PDT)
>>> From: Stefan Lisowski<s.lisowski@isti.com>
>>> Reply-To: django-users@googlegroups.com
>>> To: Django users<django-users@googlegroups.com>
>>>
>>> Hi Django folks -
>>>
>>> I'm new to Django, and I just want to use the template system now,
>>> independent of the rest of Django. But I can't get it to see a
>>> template. Even the system templates as was suggested when I started
>>> Googling for my error.
>>>
>>>>>> import django.template
>>>>>>
>>>>>>
>>>>>> django.conf.settings.configure(TEMPLATE_DIRS=('C:/Python26/Lib/site-packages/django/contrib/admin/templates/admin'),TEMPLATE_DEBUG=True,
>>>>>> DEBUG=True)
>>>>>> import django.template.loader as loader
>>>>>> loader.get_template("base.html")
>>>
>>> Traceback (most recent call last):
>>>  File "<stdin>", line 1, in<module>
>>>  File "c:\python26\lib\site-packages\django\template\loader.py", line
>>> 157, in get_template
>>>    template, origin = find_template(template_name)
>>>  File "c:\python26\lib\site-packages\django\template\loader.py", line
>>> 138, in find_template
>>>    raise TemplateDoesNotExist(name)
>>> django.template.base.TemplateDoesNotExist: base.html
>>>>>>
>>>>>> exit()
>>>
>>> C:\Program Files (x86)\Microsoft Visual Studio 8\VC>ls C:/Python26/Lib/
>>> site-packages/django/contrib/admin/templates/admin | grep base
>>> base.html
>>> base_site.html
>>>
>>> Any ideas?
>>>
>>> --
>>> 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
>>> django-users+unsubscribe@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>> --
>>> 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
>>> django-users+unsubscribe@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>
>
> --
> 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
> django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Django Standalone Template

On 10/31/2011 2:49 PM, Bill Freeman wrote:
> I think that you have too many "admin"s. Try:
>
>
TEMPLATE_DIRS=('C:/Python26/Lib/site-packages/django/contrib/admin/templates')

Thanks for the suggestion. I don't see much difference on my system here
though...

C:\Program Files (x86)\Microsoft Visual Studio 8\VC>c:\Python26\python.exe
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit
(Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django.template
>>>
django.conf.settings.configure(TEMPLATE_DIRS=('C:/Python26/Lib/site-packages/django/contrib/admin/templates'),TEMPLATE_DEBUG=True,
DEBUG=True)
>>> import django.template.loader as loader
>>> loader.get_template("base.html")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python26\lib\site-packages\django\template\loader.py", line
157, in get_template
template, origin = find_template(template_name)
File "c:\Python26\lib\site-packages\django\template\loader.py", line
138, in find_template
raise TemplateDoesNotExist(name)
django.template.base.TemplateDoesNotExist: base.html
>>> loader.get_template("admin/base.html")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\Python26\lib\site-packages\django\template\loader.py", line
157, in get_template
template, origin = find_template(template_name)
File "c:\Python26\lib\site-packages\django\template\loader.py", line
138, in find_template
raise TemplateDoesNotExist(name)
django.template.base.TemplateDoesNotExist: admin/base.html

Has anyone here used the template system successfully without using all
of Django?

>
> On Mon, Oct 31, 2011 at 3:30 PM, Stefan Lisowski<s.lisowski@isti.com> wrote:
>> I appreciate the reply SmileyChris -
>>
>> On 10/30/2011 12:41 PM, SmileyChris wrote:
>>>
>>> Take a read through this section of the docs:
>>> https://docs.djangoproject.com/en/1.3/ref/templates/api/#loading-templates
>>
>> Yes, that's what I was reading.
>>
>>> Specifically, those templates are found via the app_directories.Loader.
>>> So you'd run loader.get_template('admin/base.html') to get that
>>> template. The reason that it's in a subdirectory is to avoid conflicts
>>> with other applications (since they may want to use their own
>>> 'base.html' template.
>>
>> So, my setting TEMPLATE_DIRS here to the actual subdirectory would not work?
>>
>> TEMPLATE_DIRS=('C:/Python26/Lib/site-packages/django/contrib/admin/templates/admin')
>>
>> I used this as an example to point to some templates that are known to work,
>> rather than point to my own templates that don't work either. If I go into
>> the Django code and print out the directory that's being searched, I see the
>> correct directory there, so I don't know why things are failing. Maybe I'm
>> just not instantiating things correctly?
>>
>> In any case, I tried your suggestion, but still no luck:
>>
>>>>> loader.get_template('admin/base.html')
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in<module>
>> File "django/template/loader.py", line 164, in get_template
>> template, origin = find_template(template_name)
>> File "django/template/loader.py", line 145, in find_template
>> raise TemplateDoesNotExist(name)
>> django.template.base.TemplateDoesNotExist: admin/base.html
>>
>> (I also tried without manually setting TEMPLATE_DIRS, but just ran
>> django.conf.settings.configure(), still to no avail.)
>>
>> Anyone, any ideas? I'm completely new to Django, but I've not been working
>> in Python lately either, so it could just be a Python mistake on my part.
>>
>> - Stefan
>>
>> -------- Original Message --------
>> Subject: Django Standalone Template
>> Date: Fri, 28 Oct 2011 19:54:20 -0700 (PDT)
>> From: Stefan Lisowski<s.lisowski@isti.com>
>> Reply-To: django-users@googlegroups.com
>> To: Django users<django-users@googlegroups.com>
>>
>> Hi Django folks -
>>
>> I'm new to Django, and I just want to use the template system now,
>> independent of the rest of Django. But I can't get it to see a
>> template. Even the system templates as was suggested when I started
>> Googling for my error.
>>
>>>>> import django.template
>>>>>
>>>>> django.conf.settings.configure(TEMPLATE_DIRS=('C:/Python26/Lib/site-packages/django/contrib/admin/templates/admin'),TEMPLATE_DEBUG=True,
>>>>> DEBUG=True)
>>>>> import django.template.loader as loader
>>>>> loader.get_template("base.html")
>>
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in<module>
>> File "c:\python26\lib\site-packages\django\template\loader.py", line
>> 157, in get_template
>> template, origin = find_template(template_name)
>> File "c:\python26\lib\site-packages\django\template\loader.py", line
>> 138, in find_template
>> raise TemplateDoesNotExist(name)
>> django.template.base.TemplateDoesNotExist: base.html
>>>>>
>>>>> exit()
>>
>> C:\Program Files (x86)\Microsoft Visual Studio 8\VC>ls C:/Python26/Lib/
>> site-packages/django/contrib/admin/templates/admin | grep base
>> base.html
>> base_site.html
>>
>> Any ideas?
>>
>> --
>> 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
>> django-users+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>> --
>> 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
>> django-users+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Django Standalone Template

I think that you have too many "admin"s. Try:

TEMPLATE_DIRS=('C:/Python26/Lib/site-packages/django/contrib/admin/templates')

On Mon, Oct 31, 2011 at 3:30 PM, Stefan Lisowski <s.lisowski@isti.com> wrote:
> I appreciate the reply SmileyChris -
>
> On 10/30/2011 12:41 PM, SmileyChris wrote:
>>
>> Take a read through this section of the docs:
>> https://docs.djangoproject.com/en/1.3/ref/templates/api/#loading-templates
>
> Yes, that's what I was reading.
>
>> Specifically, those templates are found via the app_directories.Loader.
>> So you'd run loader.get_template('admin/base.html') to get that
>> template. The reason that it's in a subdirectory is to avoid conflicts
>> with other applications (since they may want to use their own
>> 'base.html' template.
>
> So, my setting TEMPLATE_DIRS here to the actual subdirectory would not work?
>
> TEMPLATE_DIRS=('C:/Python26/Lib/site-packages/django/contrib/admin/templates/admin')
>
> I used this as an example to point to some templates that are known to work,
> rather than point to my own templates that don't work either. If I go into
> the Django code and print out the directory that's being searched, I see the
> correct directory there, so I don't know why things are failing. Maybe I'm
> just not instantiating things correctly?
>
> In any case, I tried your suggestion, but still no luck:
>
>>>> loader.get_template('admin/base.html')
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "django/template/loader.py", line 164, in get_template
>    template, origin = find_template(template_name)
>  File "django/template/loader.py", line 145, in find_template
>    raise TemplateDoesNotExist(name)
> django.template.base.TemplateDoesNotExist: admin/base.html
>
> (I also tried without manually setting TEMPLATE_DIRS, but just ran
> django.conf.settings.configure(), still to no avail.)
>
> Anyone, any ideas? I'm completely new to Django, but I've not been working
> in Python lately either, so it could just be a Python mistake on my part.
>
> - Stefan
>
> -------- Original Message --------
> Subject: Django Standalone Template
> Date: Fri, 28 Oct 2011 19:54:20 -0700 (PDT)
> From: Stefan Lisowski <s.lisowski@isti.com>
> Reply-To: django-users@googlegroups.com
> To: Django users <django-users@googlegroups.com>
>
> Hi Django folks -
>
> I'm new to Django, and I just want to use the template system now,
> independent of the rest of Django. But I can't get it to see a
> template. Even the system templates as was suggested when I started
> Googling for my error.
>
>>>> import django.template
>>>>
>>>> django.conf.settings.configure(TEMPLATE_DIRS=('C:/Python26/Lib/site-packages/django/contrib/admin/templates/admin'),TEMPLATE_DEBUG=True,
>>>> DEBUG=True)
>>>> import django.template.loader as loader
>>>> loader.get_template("base.html")
>
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "c:\python26\lib\site-packages\django\template\loader.py", line
> 157, in get_template
>    template, origin = find_template(template_name)
>  File "c:\python26\lib\site-packages\django\template\loader.py", line
> 138, in find_template
>    raise TemplateDoesNotExist(name)
> django.template.base.TemplateDoesNotExist: base.html
>>>>
>>>> exit()
>
> C:\Program Files (x86)\Microsoft Visual Studio 8\VC>ls C:/Python26/Lib/
> site-packages/django/contrib/admin/templates/admin | grep base
> base.html
> base_site.html
>
> Any ideas?
>
> --
> 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
> django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> 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
> django-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Django Standalone Template

I appreciate the reply SmileyChris -

On 10/30/2011 12:41 PM, SmileyChris wrote:
> Take a read through this section of the docs:
> https://docs.djangoproject.com/en/1.3/ref/templates/api/#loading-templates

Yes, that's what I was reading.

> Specifically, those templates are found via the app_directories.Loader.
> So you'd run loader.get_template('admin/base.html') to get that
> template. The reason that it's in a subdirectory is to avoid conflicts
> with other applications (since they may want to use their own
> 'base.html' template.

So, my setting TEMPLATE_DIRS here to the actual subdirectory would not work?

TEMPLATE_DIRS=('C:/Python26/Lib/site-packages/django/contrib/admin/templates/admin')

I used this as an example to point to some templates that are known to
work, rather than point to my own templates that don't work either. If I
go into the Django code and print out the directory that's being
searched, I see the correct directory there, so I don't know why things
are failing. Maybe I'm just not instantiating things correctly?

In any case, I tried your suggestion, but still no luck:

>>> loader.get_template('admin/base.html')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "django/template/loader.py", line 164, in get_template
template, origin = find_template(template_name)
File "django/template/loader.py", line 145, in find_template
raise TemplateDoesNotExist(name)
django.template.base.TemplateDoesNotExist: admin/base.html

(I also tried without manually setting TEMPLATE_DIRS, but just ran
django.conf.settings.configure(), still to no avail.)

Anyone, any ideas? I'm completely new to Django, but I've not been
working in Python lately either, so it could just be a Python mistake on
my part.

- Stefan

-------- Original Message --------
Subject: Django Standalone Template
Date: Fri, 28 Oct 2011 19:54:20 -0700 (PDT)
From: Stefan Lisowski <s.lisowski@isti.com>
Reply-To: django-users@googlegroups.com
To: Django users <django-users@googlegroups.com>

Hi Django folks -

I'm new to Django, and I just want to use the template system now,
independent of the rest of Django. But I can't get it to see a
template. Even the system templates as was suggested when I started
Googling for my error.

>>> import django.template
>>> django.conf.settings.configure(TEMPLATE_DIRS=('C:/Python26/Lib/site-packages/django/contrib/admin/templates/admin'),TEMPLATE_DEBUG=True, DEBUG=True)
>>> import django.template.loader as loader
>>> loader.get_template("base.html")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "c:\python26\lib\site-packages\django\template\loader.py", line
157, in get_template
template, origin = find_template(template_name)
File "c:\python26\lib\site-packages\django\template\loader.py", line
138, in find_template
raise TemplateDoesNotExist(name)
django.template.base.TemplateDoesNotExist: base.html
>>> exit()
C:\Program Files (x86)\Microsoft Visual Studio 8\VC>ls C:/Python26/Lib/
site-packages/django/contrib/admin/templates/admin | grep base
base.html
base_site.html

Any ideas?

--
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
django-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Dynamic URLs or creating querysets from your URL paths.

Sure you could do that. It's called using XML Transformations (XSLT), Javascript Templatating Engines, or a number of other approaches. 

Django does this with its Template Engine. The reason this isn't completely ran on the Client-Side is because it would be slower, difficult to cache, and dependent upon some specific Client-Side technologies.

Django lets you easily override this behavior. For example, there's documentation on using alternative Templating Engines. You could apply the same methodology to using Client-Side Templating Engines (written in Javascript), or even just displaying XML w/ XSLT using the Browser's Transformation Engine. I'm not really the most experienced person when it comes to Client-Side templates but I'm sure there's a lot out there in Google Land.

On Mon, Oct 31, 2011 at 1:04 PM, Timmy O'Mahony <t.omahony.dublin@gmail.com> wrote:
The more I think about this the more I realize that what I'm talking about IS exactly a REST api.

If I write a phone app, I will code all the presentation layer locally on the phone (client-side) and use json/xml to dynamically fetch data from the server. 

Why isn't this the same for websites? - why isn't the presentation layer completely client-side as opposed to 'a bit of both'?

Ideally when a user requests a webpage from my server, I should deliver the presentation layer to them, along with the information they require to perform an API lookup. From then on they can query my server using the same REST api a phone app would use. This would mean that all the information from EVERY device accessing my website comes from the same api. This is much better then my existing setup, where I might have an API for an app to accompany my site, but I also have a jungle of urls and views to enable a web browser use my site

Am I just repeating/realizing something that is well know and catered for? 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/f1xLB5KuZQAJ.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Re: Dynamic URLs or creating querysets from your URL paths.

The more I think about this the more I realize that what I'm talking about IS exactly a REST api.

If I write a phone app, I will code all the presentation layer locally on the phone (client-side) and use json/xml to dynamically fetch data from the server. 

Why isn't this the same for websites? - why isn't the presentation layer completely client-side as opposed to 'a bit of both'?

Ideally when a user requests a webpage from my server, I should deliver the presentation layer to them, along with the information they require to perform an API lookup. From then on they can query my server using the same REST api a phone app would use. This would mean that all the information from EVERY device accessing my website comes from the same api. This is much better then my existing setup, where I might have an API for an app to accompany my site, but I also have a jungle of urls and views to enable a web browser use my site

Am I just repeating/realizing something that is well know and catered for? 

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

Dynamic URLs or creating querysets from your URL paths.

I'm creating a CMS using django-cms and some custom plugins. Everytime I do this I get sick or writing the same views time and time again.

Quick example, I have a Project model that can have one or more Categories, Tags and Clients:

class Project(...)
    categories = models.ManyToManyField(Category)
    tags = models.ManyToManyField(Tag)
    clients = models.ManyToManyField(Client)

I want the user to be able to browse my projects by a certain category, or tag or client. So my urls would be something like:

url(r'^projects/category/(?P<slug>[-w]+)/$', ...
url(r'^projects/partner/(?P<slug>[-w]+)/$', ...
url(r'^projects/client/(?P<slug>[-w]+)/$', ...

allowing me to see all projects for particular relationships, and maybe

url(r'^projects/category/$', ...
url(r'^projects/partner/$', ...
url(r'^projects/client/$', ...

to list all categories, partners and clients. 

This seems totally anti-DRY (WET?) to me. I'd like to be able to dynamically create the query based on what the URL path is, instead of having to manually link the URL paths to the correct queries via views as it stands at the moment. So retrieve the correct model based on what path is supplied - somewhat like a REST API call. Does anyone have any thoughts on this approach, or Is there anything out there that caters for this? 

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