django-generic-views

Generic Views from the object_id or the parent object

I have a model that represents a position at a company: class Position(models.Model): preferred_q = ForeignKey("Qualifications", blank=True, null=True, related_name="pref") base_q = ForeignKey("Qualifications", blank=True, null=True, related_name="base") #[...] It has two "inner objects", which represent minimum qualifica...

NoReverseMatch Exception help in Django

Hi--I'm fairly new to python and following along with part 4 of the tutorial for the Django framework here. I'm trying to implement generic views for the polls app--my code seems correct (as far as I can tell), but when I try to vote, I get a NoReverseMatch Exception that states: Reverse for 'polls/poll_results' with arguments '(1L,...

Django generic view, and " most view " article

Hi guys, im using generic view, i would like to update a field (most_view) in another database table. How ill update or create a new register for "most view" when the user are reading a article? ulrs.py from Paso_a_Paso.noticias.models import Noticia noticias_info_dict = { 'queryset':Noticia.objects.all(), 'date_field...

Django: use archive_index with date_field from a related model

Hello (please excuse me for my ugly english :p), Imagine these two simple models : from django.contrib.contenttypes import generic from django.db import models class SomeModel(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField(_('object id')) content_object = generic.Generi...

How to approach creating Related Links generic (like Comments/Tags) in Django

Since I have not found a Related Links app that works with Django 1.0/trunk, I was looking to create my own. I would like to attach "Related Links" to models in the same generic way that Comments framework or Tags work. I've looked over the Content Types documentation but can't wrap my head around (nor find much documentation for) ho...

Can I use Django's Generic Views with google-app-engine-django?

Put simply, is there a way to get generic views to work? If I try the following in urls.py: publisher_info = { 'queryset': Publisher.objects.all(), } urlpatterns = patterns('', (r'^publishers/$', list_detail.object_list, publisher_info) ) I get the following error: AttributeError at /publishers 'Query' object has no a...

Pass a form created with captured url parameters to a generic django view?

This seems like it should be obvious, but the solution is eluding me. Normally I would just write a simple view function which would populate an appropriate form and pass it along to the view, but the solution feels so close .. I have a form. I want to instantiate this form using an object_id that I've captured in the url, then send it ...

URL to date-based generic view in django template?

Is there an easy way to get the URL to a Django date-based generic view (specifically object_detail) from a template? Given a URL conf like this url(r'^posts/(?P<year>\d\d\d\d)/(?P<month>\d\d)/(?P<day>\d\d)/(?P<slug>[\w-]+)$', 'date_based.object_detail', detail_info, name='blog-post-detail') My understanding is that I would need to d...

Django generic views with multiple parameters

Is it possible to use a generic view with additional parameters in the URL mapping - i.e. I got the following model: class Route(models.Model): area = models.ForeignKey(Area) slug = models.SlugField(null=True,blank=True) @models.permalink def get_absolute_url(self): return ('route_details', (), {'area': self.are...

django dynamic Q objects in generic view

Hi, I want to be able to pass a variable caught in the URL to a Q object for a generic view. I created a generic view which is imported as my_views.view which handles things like pagination, sorting, filtering etc... I need to use Q objects because for some pages there will need some OR filters. Each page will also be filtering based o...

Pass model from url to create_object generic input view

I have multiple models that I want to create generic inputs for. My first pass used two separate urls: url(r'^create_actor/$, create_object, {'model': Actor, 'template_name': 'create.html', 'post_save_redirect': '/library/', 'extra_context': {'func': 'Create Actor'}, 'login_required': 'True'}), url(r'^create_movie/$, create_object, {'...

Django: Display Generic ModelForm or predefined form

I have 3 models with various fields in each. For 2 of the models, I'm fine with using a generic form (through Django's create_object) to request data. I wrote a function that accepts the model name and sends the user to the generic form url(r'^add_(?P<modelname>\w+)/$', generic_add), def generic_add(request, modelname): mdlnm_mod...

django python - generic views and cookies

Hi, I made in my web a menu using generic_view - simple 'django.views.generic.list_detail.object_list' in urls.py file. I would like to set a cookies each time when user chooses one of element of this list [HttpResponse.set_cookie(...)]. What is the best solution? Should I write function in views.py or have you got more simple solution? ...

In plain English, what are Django generic views?

The first two paragraphs of this page explain that generic views are supposed to make my life easier, less monotonous, and make me more attractive to women (I made up that last one): http://docs.djangoproject.com/en/dev/topics/generic-views/#topics-generic-views I'm all for improving my life, but what do generic views actually do? It s...

Django throws 404 at generic views

I'm trying to get the generic views for a date-based archive working in django. I defined the urls as described in a tutorial, but django returns a 404 error whenever I want to access an url with a variable (such as month or year) in it. It don't even produces a TemplateDoesNotExist-execption. Normal urls without variables work fine. He...

Problem using generic views in django

I'm currently working with django generic views and I have a problem I can't figure out. When using delete_object I get a TypeError exception: delete_object() takes at least 3 non-keyword arguments (2 given) Here is the code (I have ommited docstrings and imports): views.py def delete_issue(request, issue_id): return delete_obj...

How to get first top five objects with django.views.generic.date_based.archive_index?

Hello, I'm trying to display the latest 5 posts using a generic view like this: urlpatterns = patterns('', (r'^$', 'django.views.generic.date_based.archive_index', { 'queryset': Post.objects.all()[:5], 'date_field': 'created_on', 'template_name': 'index.html'} }) However I am getting AssertionError at...

object_detail() got multiple values for keyword argument 'queryset' while inputting only one

from django.conf.urls.defaults import * from django.conf import settings from Website.Blog.models import Post # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() index = { 'queryset': Post.objects.all(), 'date_field': 'created_on', 'template_name':...

How to load the template_name for a generic view from the database?

I have a model that has a template_name field and I have this generic view: url(r'^/post/(?P<slug>[a-zA-Z0-9_.-]+)$', 'django.views.generic.list_detail.object_detail', { "template_object_name" : "post", 'template_name': 'post_details.html' }, 'index') How can I replace the template_name from 'post_details.html' t...

Filter results for Django paginator in template

I'm filtering out results from my page_obj in a generic view to only show entries published in the same language as the languge currently set by django-cms (http://www.django-cms.org/en/documentation/2.0/i18n/). This works fine, but adding in support for Django pagination (http://docs.djangoproject.com/en/1.2/topics/pagination/) causes ...