Seeking sample template code for iterating nested QuerySet
The documentation at: https://docs.djangoproject.com/en/1.3/topics/db/queries/ Speaks of "Spanning multi-valued relationships", with an QuerySet returning all Entries (and their Blogs) where the Blog matches a pattern. What does the view code look like? When I do something similar: facets= models.Category.objects. filter(facetquestion__facetanswer__subject='test'). select_related() {% for category in answers %} {% for q in category.facetquestion_set.all %} {% for a in q.facetanswer_set.all %} {% endfor %} {% endfor %} {% endfor %} Each '_set.all" returns the entire set, not just those entries that matched a pattern. Back to the django documentation: how would I write the view for the example given: Blog.objects.filter(entry__headline__contains='Lennon',entry__pub_date__year=2008) Where I want the view to print: Blog1 Entry1 "Lennon On Ice" Entry2 "Lennon In Love" Blog4 Entry9 "Lennon is Killed" -- 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: Working Django forums code for integration?
I've had the same problem. > > AskBot : not a real forum, and a lot of dependencies. PyBBM: install instructions incomplete, no community to speak of, buggy. I had problems with csrf, and could not get any help. Cnprog: dead PyBB: dead DjangoBB: website reads "Documentation will be soon..." -- 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/-/_cWicZJM94AJ. 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: Working Django forums code for integration?
Are there any forum packages not listed at > > http://www.djangopackages.com/grids/g/forums/ -- 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/-/OefJfoaDiVoJ. 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.
'CSRF verification failed." from django.contrib.comments. can you help solve it? django 1.3
I'm using django.contrib.comments and get 'CSRF token missing or incorrect.' when previewing or submitting a comment. I have: *MIDDLEWARE_CLASSES = (* *'django.middleware.csrf.CsrfViewMiddleware',* *'django.middleware.common.CommonMiddleware',* *'django.contrib.sessions.middleware.SessionMiddleware',* *'django.contrib.auth.middleware.AuthenticationMiddleware',* *'django.contrib.messages.middleware.MessageMiddleware',* *)* url(r'^comments/', include('django.contrib.comments.urls')), url(r'^entry/(?P\d+)/comment', 'rp2.views.entry_comment_add'), @csrf_protect #does not matter if this is here or not def entry_comment_add(request, pk): entry = models.Entry.objects.get(pk=pk) assert isinstance(entry, models.Entry) return render(request, 'entry_comment_popup.html', {'entry':entry}) {% extends 'head-plain.html' %} {% load comments %} {% block content %} {% render_comment_form for entry %} {% endblock %} The HTML looks like it has the csrf security_hash in the proper place: http://127.0.0.1:8000/comments/post/>" method="post"> ... I have read https://docs.djangoproject.com/en/dev/ref/contrib/comments/ -- 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/-/TDG0eAHHlkkJ. 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: 'CSRF verification failed." from django.contrib.comments. can you help solve it? django 1.3
The "security_hash" field that you see is part of the comments app, and is > not the CSRF token. That needs to be output by a {% csrf_token %} tag (or > its equivalent). If it's working, you should see another hidden input > field, which looks like this: > > > value="36d43c1652d5676d6d411950e077eeaa1cc1f799"/> > > > The comments app normally does that automatically -- it's part of > django/contrib/comments/templates/form.html -- Are you overriding the > comment form in your own app? If so, you need to include the call to {% > csrf_token %} yourself. > I am not overriding, at least not deliberately. django/contrib/comments/templates/form.html has: {% load comments i18n %} {% csrf_token %} I render my form with: {% render_comment_form for entry %} --- I should note it did work when I first added it to the application. It broke after I added pybbm. I've since removed pybbm (it is maintained and broken), but comments started getting csrf errors. -- 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/-/pykynQInFVUJ. 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: 'CSRF verification failed." from django.contrib.comments. can you help solve it? django 1.3
On Thursday, June 28, 2012 10:43:58 AM UTC-7, jonas wrote: > > After the starting form tag add {% csrf_token %} > I can't. It is rendered for me by {% render_comment_form for entry %} -- 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/-/P_1zIG9fUC4J. 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.
m2m through intermediate model: template friendly syntax not working. dj1.3
I'm able to get an intermediate m2m model to show data, but not with the template-friendly "_set" syntax: category= models.Category.objects.select_related().get(pk=pk) entries = category.entry.order_by('-temp_sort_order').filter(temp_sort_order__gte=0) for entry in entries: assert isinstance(entry, models.Entry) ce = models.CategoryEntry2.objects.get(entry=entry, category=category) pprint('1: ' + ce.wiki + str(entry.ce)) foo = entry.ce_set.get(category=category) #'Entry' object has no attribute 'ce_set' pprint('2: ' + foo.wiki + str(foo.ce)) #'Entry' object has no attribute 'ce_set' for entry in category.ce_set.all: #'Category' object has no attribute 'ce_set' pprint('1: ' + entry.wiki) Any ideas? class Category(models.Model): title = models.CharField(max_length=1024,null=True,blank=True) entry = models.ManyToManyField(Entry,null=True,blank=True, related_name='ce', through='CategoryEntry2', ) -- 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/-/kYgWEzIQjrgJ. 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: 'CSRF verification failed." from django.contrib.comments. can you help solve it? django 1.3
It works now that I have fully uninstalled pybbm. Pybbm was incompatible with my app because it also extended the User object (something apparently you can only do once?) -- 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: m2m through intermediate model: template friendly syntax not working. dj1.3
> > Using 'for entry in category.ce_.all', as suggested elsewhere also fails >> > > -- 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/-/qVATgZeGAWMJ. 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: m2m through intermediate model: template friendly syntax not working. dj1.3
I'm still stuck on this. Is there any tutorial example that shows access m2m intermediate model data from a template. The issue is the template library won't accept parameters. Do I have to write a custom tag to get the m2m intermediate data fields? -- 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/-/xY_5d2gz3l8J. 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.
Seeking example of django.contrib.staticfiles usage
I'm evaluating frameworks, writing the same app different ways. I've run smack into Django's static file handling. I understand that with Django my basic options for static files are: 1) Static files on a separate web server 2) Configure apache to send some content to Django, serve some statically. 3) Have django.contrib.staticfiles to serve static content (perhaps non-optimally) from the Django runtime. Is there a simple example of #3 (the only one that lets me package up a complete "app")? I've read: https://docs.djangoproject.com/en/dev/howto/static-files/ And trolled the forums. Both make it seem much more complicated than it probably actually is. There's a lot of cruft in the document. And when I add "django.contrib.staticfiles" the runtime simply reports "Error: No module named staticfiles". Is there a good working tested example out there? # django-admin.py --version 1.2.5 -- 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.
Cache witin a single transaction / session ?
Does there exist a lightweight cache option for django which persists data in a single session. For example: {{gallery.tiles.count}} item{% if gallery.tiles.count != 1 %}s{% endif %} Produces two count() operations on the underlying database. Is there a way to make that one operation? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.