Questions tagged [django-generic-views]

Questions about Django’s built-in generic views, which helps you to avoid repeating common code patterns in every project.

Questions about Django’s built-in generic views, which helps you to avoid repeating common code patterns in every project.

568 questions
0
votes
1 answer

Update selected objects from ListView in Django

I have a ListView in which I list all objects in a table. Every row has a checkbox. I am trying to update the objects whose checkbox is marked with a formset in another view, but I don't know how to send the user to my update view with the post data…
Nets
  • 141
  • 8
0
votes
1 answer

Django ListView pagination using Form

I'm trying to pass "form" as context, my code: class BlogSearchView(ListView): model = Blog paginate_by = 20 template_name = "base/blog_search.html" def get_queryset(self): qset = super(BlogSearchView, self).get_queryset() …
Soy Latam
  • 182
  • 1
  • 2
  • 10
0
votes
1 answer

Django 1.5: How to use generic views?

I am trying to use the Generic Views in Django 1.5 and its kind of confusing. So far I have been using functions within views.py. I agree that the function approach has more boilerplate code, but at the same time you have more control over it as a…
Houman
  • 64,245
  • 87
  • 278
  • 460
0
votes
1 answer

Can I make a view using UpdateView and DeleteView together?

I am looking for some information about generic views in django. I want a page that will render a form for an object. On my page I want one submit button to update the object and another submit button that will delete the object. Is it a possible…
0
votes
1 answer

Error passing the username to a Generic DetailView - django 1.4.3

First of all, I have read this django username in url, instead of id it helped, but did not solve my problem. I do not want to write any code in views.py if I can help it. Things I've tried under urls.py. Note: In both cases I get name 'username'…
nu everest
  • 9,589
  • 12
  • 71
  • 90
0
votes
1 answer

redundant django code

I have some code that I wrote and it works perfectly fine for its purpose. from django.shortcuts import get_object_or_404 from django.views.generic import ListView from cab.models import Language class LanguageDetail(ListView): def…
AmrFouad
  • 31
  • 1
0
votes
2 answers

How to pass form to Class-based generic views(TodayArchiveView)?

url.py from django.conf.urls import patterns, include, url import os.path from crm.views import * urlpatterns += patterns('', (r'^test/$', tView.as_view()), ) views.py from django.views.generic import TodayArchiveView from crm.forms import…
chobo
  • 4,830
  • 5
  • 23
  • 36
0
votes
1 answer

Why I get a this error that invalid syntax (urls.py, line 34)

my url.py from django.conf.urls import patterns, include, url import os.path from crm.views import * (r'^workDailyRecord/(?P\w+/)?$', workDailyRecord), (r'^user/search/$', searchUser), # (r'^tset/$', mainPage), # (r'^ptpt/$',…
chobo
  • 4,830
  • 5
  • 23
  • 36
0
votes
1 answer

Django: Category List - view's

I have model in models.py: class Category(models.Model): name = models.CharField('Nazwa Kategorii', max_length=100) slug = models.SlugField('Odnośnik', unique=True, max_length=100) icon = models.ImageField('Ikonka Kategorii',…
Piszu
  • 443
  • 1
  • 8
  • 24
0
votes
1 answer

Omit day keyword argument from Django's date_based generic view?

I don't want to have the day in the URL for a detail view while using Django's dated_based generic views. I tried the following but get a TypeError at /logbook/2013/january/testing/ object_detail() takes at least 6 arguments (7…
sgriffee
  • 381
  • 5
  • 18
0
votes
1 answer

Django generic view, and " most view " article

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…
Asinox
  • 6,747
  • 14
  • 61
  • 89
0
votes
1 answer

Convert django function generic view into class-based generic view

I've added a "user" field to all of my models. When a user creates an object, I want to attach their ID through a foreign key user = models.ForeignKey(User) Previously, I was using create_object and update_object. I believe I need to switch to…
Ed.
  • 4,439
  • 10
  • 60
  • 78
0
votes
1 answer

Django registration: Redirect after login

I am using django registration and I want to be redirected on an other page after login. I used in settings.py: LOGIN_REDIRECT_URL = 'http://127.0.0.1:8000/home/' That's the page I want to be redirected to. I succeed in redirecting. But the page…
user1507156
  • 539
  • 1
  • 7
  • 12
0
votes
2 answers

direct_to_template and render_to_response on templates - {{request}}

These functions should not work exactly the same? def IndexView(request): return direct_to_template(request, template='index.html') def IndexView2(request): return render_to_response('index.html', {'request':…
cleliodpaula
  • 819
  • 2
  • 11
  • 27
0
votes
1 answer

Django travel up or down relationships in a generic way

I am trying to rewrite my Django code to make it as generic as possible on all levels. Say I have the following models: class Tvshow(models.Model): pass class Season(models.Model): tvshow = models.ForeignKey(Tvshow) class…
tBuLi
  • 2,295
  • 2
  • 16
  • 16
1 2 3
37
38