django-class-based-views Questions

2

Solved

Is it possible to pass multiple models into the UpdateView? Something like: models = (FirstModel, SecondModel)
Oxbow asked 10/7, 2013 at 7:46

5

Solved

Question: I'm trying to access an attribute of the view instance in the middleware layer. For example, given a class-based view like this: # views.py class MyView(View): my_attribute = 'somethi...
Ossuary asked 21/12, 2013 at 4:48

9

Solved

I have the following code for serializing the queryset: def render_to_response(self, context, **response_kwargs): return HttpResponse(json.simplejson.dumps(list(self.get_queryset())), mimetype=&...

5

Solved

If I have a class based view, like this, class SomeView (View): response_template='some_template.html' var1 = 0 var2 = 1 def get(self, request, *args, **kwargs): return render_to_response(s...

8

Solved

Say I want to create a Class Based View which both updates and creates an object. From a previous question I worked out I could do one of the following things: 1) Use 2 generic views CreateView an...

2

Solved

I have a class based ListView of which I would like to filter the objects by the logged in user_id since Item model has a foreign key to settings.AUTH_USER_MODEL class ItemListView(LoginRequiredMi...

3

Solved

I´m using CBV in Django to delete items. What I want to do is when I click the button to remove, instead of redirecting me to the post_confirm_delete view I want to pop up a modal in which I show t...

6

Solved

What's the best way to add a "cancel" button to a generic class-based view in Django? In the example below, I would like the cancel button to take you to success_url without deleting the object. I...
Manton asked 16/7, 2013 at 14:3

3

Solved

i am developing a simple app with python django framework and i am using Class based Views, when i use the UpdateView and try to run my template i get this error; 'QuerySet' object has no attribut...
Chapple asked 24/8, 2017 at 8:24

2

Solved

I am trying to implement an appointment-making application where users can create sessions that are associated with pre-existing classes. What I am trying to do is use a django CreateView to create...
Dornick asked 16/10, 2014 at 15:11

3

Solved

Assuming I have the following FormView and i want to pass the item.pk to some other view after the form is submitted. I guess i have to edit get_success_url() but i can't even figure out how to get...
Sacristy asked 1/7, 2018 at 12:24

2

Solved

I'm working on a Django project and trying to figure out how I can test for user ownership and allow editing or redirect based on the result. I have a model Scene. Scene is linked to User to trac...

3

Solved

EDIT: The better solution for me was just using a permissions system, especially since I needed other types of controlled access to objects. I now use Django-guardian to help with object level per...
Nathalienathan asked 11/8, 2013 at 12:53

6

Solved

I have a DeleteView: class LectureDelete(SuccessMessageMixin, DeleteView): model = Lecture success_message = "Die Veranstaltung wurde gelöscht" success_url = '/' def get_object(self): qs = supe...
Avaria asked 18/7, 2014 at 10:11

7

Solved

I am trying to realize a Class Based ListView which displays a selection of a table set. If the site is requested the first time, the dataset should be displayed. I would prefer a POST submission, ...
Tynan asked 16/11, 2012 at 12:22

4

Solved

I have a very simple Class Based View: In views.py: class IncidentEdit(UpdateView): model=Incident fields = visible_field_list sucess_url = '/status' works fine as-is. I have associated Crea...

3

Solved

I have a page with a list of users, and would like to be able to click a link to update their profile. When 'update' is clicked, I should be able to edit the username, first name, ... email, phone ...
Trihedron asked 8/8, 2013 at 9:10

4

Solved

I'm using the CreateView of Django and I'm trying to find out how I can modify any text which gets sent before it gets saved. For example, right now I'm only looking to lowercase all the text befor...
Forspent asked 12/12, 2018 at 11:33

5

I have a class QuestionView which is derived from the FormView class. Here is a code snippet to explain my problem: class QuestionView(FormView): ... context_var1 = y def form_valid (self, form...
Crymotherapy asked 2/8, 2011 at 4:50

5

Solved

Sorry if this is a trivial question but I've been searching around for quite sometime and have been unable to find a good implementation. Can someone provide an example of how to implement a post-...
Dianoia asked 26/4, 2016 at 8:39

9

Solved

I'm trying to do cache_page with class based views (TemplateView) and i'm not able to. I followed instructions here: Django--URL Caching Failing for Class Based Views as well as here: https://gi...
Cragsman asked 22/1, 2014 at 20:42

2

Solved

I have a problem when I want to paginate the filter that I create with django_filter, in my template it shows me the query set and filter but paginate does not work, I would like to know why this h...

2

Solved

I have a hard time understanding class based views in Django. At this time I try to implement a request.session in a ListView. I try to implement the following function based code from the MdM Djan...
Essay asked 20/12, 2019 at 21:33

3

Solved

The example in the documentation, https://django-filter.readthedocs.org/en/latest/usage.html, is I think for a function based view. I am currently researching how to do this with a class based view...
Unlive asked 19/6, 2014 at 11:48

4

Solved

I've got FormView that redirect to a previous page if the form was valid. That's works fine but how can I tell a user that the information has been posted? I want him to see a success message in a ...
Bunch asked 4/6, 2016 at 17:56

© 2022 - 2024 — McMap. All rights reserved.