Using named groups from choices
I'm trying to use the named group from nested choices in my model as part of the url. I currently have: model.py class Project(models.Model): PROJECT_CHOICES = ( ('Residential', ( ('public', 'Public Houses'), ('private', 'Private Houses'), ('extensions', 'Extensions'), ) ('Public', ( ) type = models.CharField(max_length=1, choices=PROJECT_CHOICES) title = models.CharField(max_length=100, verbose_name="Project Name", unique=True) def get_absolute_url(self): return "/projects/%s/%s/" % (self.type, self.title) This works but I'd like to use the named group to produce urls like: .../projects/residential/private/boldt-castle Obviously, I can do this manually but there should be a way of accessing the named group Thanks. --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Simple 'static' sitemap
For anyone looking for the most basic "static" sitemap you could use: Views. def dlsitemap(request): sitemap_data = open('path/to/templates/sitemap.xml',).read() return HttpResponse(sitemap_data, mimetype="text/xml") URLS (r'^sitemap\.xml$', 'dlsitemap'), All the examples I found where for dynamic sitemaps. (Please correct any errors) --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Simple Sitemap
Thanks Adam. I've had a look at the django.contrib.sitemaps process but all examples I've found relate to dynamic sitemaps created for ever changing blogs etc. Most of the info gives an example of a file to create but not what to call it or where to put it. So, using my limited knowledge of django and python i cobble something together and get ... an Unhandled exception. Arg. On 12 Oct, 20:30, Adam N <a...@varud.com> wrote: > You might as well use django.contrib.sitemaps. > > It's not difficult to use that app so there's no more efficient way to > do this unless you happen to have the sitemaps.xml file already. > > On Oct 12, 11:32 am, Timbadu <t...@soundslikedesign.co.uk> wrote: > > > I need a simple sitemap for 5 URLs. The django sitemaps app seams a > > bit overkill for such a simple xml file. > > What's the best way of doing this? > > Can i simply upload a sitemaps.xml and point to it? > > Or should i use the django.contrib.sitemaps? > > > Thanks, --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Simple Sitemap
I need a simple sitemap for 5 URLs. The django sitemaps app seams a bit overkill for such a simple xml file. What's the best way of doing this? Can i simply upload a sitemaps.xml and point to it? Or should i use the django.contrib.sitemaps? Thanks, --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: meta or QuerySet - I don't know
Thanks Tim, I wrapped it in a div and daisy-chained some filters so as to allow the js file find the class tags. {% for genre in genre_list %} {{ genre.genre_type }} {% for credit in genre.credit_set.all %} {{ credit.title }} {% endfor %} {% endfor %} --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
meta or QuerySet - I don't know
Hi folks, (New to databasing) I'm looking for a solution for presenting MySQL. I want to display my data grouped by a colmn value in the MySQL table. So my model is: from django.db import models class Genre(models.Model): genre_type = models.CharField(max_length=40) def __unicode__(self): return self.genre_type class Credit(models.Model): date = models.DateField() title = models.CharField(max_length=80) company = models.CharField(max_length=80, blank=True, null=True) genre = models.ForeignKey(Genre) underwater = models.BooleanField('Underwater credit') latest_tag = models.BooleanField('Display as recent credit') def __unicode__(self): return self.title I want to extract all the "credits" and group them into genre and display them inside a div with h5 both showing the genre: Commercials Lidl Flybe Arnold Clark Wholesale Domestic Evening Times Daily Record to look like this: http://www.davidlees.tv/lightingcameraman/ I've tried all sorts of stuff in my views.py file and it wont work. Any help or pointers would be great. Thanks --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Tutorial 3 templates
Hi folks, I'm working throu the Django Tutorials and am on no. 3. No matter where I put my 404.html and 500.html template files I am always getting this traceback: Traceback (most recent call last): File "C:\Python26\lib\site-packages\django\core\servers \basehttp.py", line 278, in run self.result = application(self.environ, self.start_response) File "C:\Python26\lib\site-packages\django\core\servers \basehttp.py", line 635, in __call__ return self.application(environ, start_response) File "C:\Python26\lib\site-packages\django\core\handlers\wsgi.py", line 239, in __call__ response = self.get_response(request) File "C:\Python26\lib\site-packages\django\core\handlers\base.py", line 116, in get_response return self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "C:\Python26\lib\site-packages\django\core\handlers\base.py", line 160, in handle_uncaught_exception return callback(request, **param_dict) File "C:\Python26\lib\site-packages\django\views\defaults.py", line 23, in server_error t = loader.get_template(template_name) # You need to create a 500.html template. File "C:\Python26\lib\site-packages\django\template\loader.py", line 80, in get_template source, origin = find_template_source(template_name) File "C:\Python26\lib\site-packages\django\template\loader.py", line 73, in find_template_source raise TemplateDoesNotExist, name TemplateDoesNotExist: 500.html I've been strugglin with this for a while now but can't work it out. Can anyone see what I'm doing wrong? Thanks, Tim --~--~-~--~~~---~--~~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---