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

limiting related object queryset on Django view based on permissions

I am reading Andrew Pinkham's Django Unleashed as an intro to learning Django and see an unresolved issue in the viewing of related objects in an object's views. Here's a simple explanation: Startups have related blog posts. Viewing of blog posts is…
calJersey
  • 1
  • 1
0
votes
1 answer

How to use Django's DetailView (or some built-in view class) for a home page?

I'm building an app in Django and I would like to set up a home page for authenticated users. I thought it was best to use de built-in generic.DetailView for this, given that the details I want to show in the page are those of the identified user.…
coya
  • 264
  • 2
  • 15
0
votes
0 answers

Heirarchy Trees from Objects.all() with Generic Views in Django

I'm working on a blog using Django. I'm using Generic Views ie. from django.views.generic import dates from django.views.generic.list import ListView These are working fine but I also wanted to implement a searchable, collapsable tree in the blog…
jayuu
  • 443
  • 1
  • 4
  • 17
0
votes
1 answer

Django class based view pagination

Hi i want to paginating queryset(lectures). and i tried. but it doesn'work how can i do? class tag_detail(View): def get(self, request, pk): tag_hit = get_object_or_404(TagModel, id=pk) tag_hit.view_cnt =…
0
votes
0 answers

Django Heroku CreateView Post Bad Request 500 in Production only

I'm deploying a Django App live for the first time, and everything has gone relatively smoothly so far. My site works fine, except for one CreateView (EstRequestCreateView) that works locally, but when I try to create new Estimate Request in…
whieronymus
  • 301
  • 4
  • 15
0
votes
1 answer

Take last object in queryset and set value in field

I have app in Django 1.8 and I want to take last object (based on pub_date) and set for this object filed is_mainteaser on True and rest ssould be set on False. Here is my code, but latest object hasn't field set to True. class…
git-e
  • 269
  • 1
  • 4
  • 15
0
votes
2 answers

Bringing Information from django.contrib.auth.models.User into View

I have the following model in my Django project: from django.contrib.auth.models import User class Project(models.Model): project_title = models.CharField(max_length=200) project_description = models.CharField(max_length=200, default="") …
MadPhysicist
  • 5,401
  • 11
  • 42
  • 107
0
votes
1 answer

Why does my Django view display the correct model fields without the data?

I'm trying to create a user profile for my users with Django. Overall it seems to have mostly worked and I am able to see everything correct in the admin page. On my actual HTML page I correctly see the model fields that I need, however they aren't…
RknRobin
  • 391
  • 2
  • 6
  • 21
0
votes
0 answers

Django: Redirect from a form

I'm writing a sports league app. I get a drop down list of all my teams. And I can display the wins/losses data on a separate view. But I can't get the StandingsView (with the form) to correct redirect to the TeamView (display information). I've…
0
votes
1 answer

object has no attribute get while overriding the POST method

class CreatePosts(CreateView): model = posts fields = ['title','comments'] def post(self, request, *args, **kwargs): current_inspectionfile = Inspectionfile.objects.get(pk = self.kwargs['pk']) new_post = …
0
votes
1 answer

How to link foreign key in a class based view in Django

class IndexView(generic.ListView): template_name = "posts/index.html" def get_queryset(self): return Inspectionfile.objects.all() class DetailView(generic.DetailView): model = Inspectionfile template_name =…
0
votes
1 answer

Detail template in Django not taking values

from django.views import generic from .models import Inspectionfile from .models import posts class IndexView(generic.ListView): template_name = "posts/index.html" def get_queryset(self): return Inspectionfile.objects.all() class…
0
votes
2 answers

Django : Passing a list as arguments to generic create view from html page

I am making a portal for the procedure of Interview rounds. My basic code is as follows: models.py class Round(models.Model): pending_students = models.ManyToMany(User, related_name='pending_student', blank=True) done_students =…
0
votes
1 answer

Django generic View for dealing with two forms occur errors

I'm trying to make django views for dealing with two forms. This kind of view is used for 'signup' and 'login' are in same template(For instance, modal structure, e.g http://bootsnipp.com/snippets/featured/login-amp-signup-forms-in-panel) And I got…
user3595632
  • 5,380
  • 10
  • 55
  • 111
0
votes
1 answer

CreateView + redefinition of form_valid = didn't return an HttpResponse object

Django 1.10strong text Could you help me understand why this results in: The view wiki.views.WikiCreate didn't return an HttpResponse object. It returned None instead. post: I didn't interfere with the chain of inheritance when redefining post…
Michael
  • 4,273
  • 3
  • 40
  • 69