django-generic-views Questions

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...

19

I'm trying to expand the submit button so that it is the size of the password field. I am using the code btn-block but it's not working. <div class="container"> <div class="row" style="m...
Threadbare asked 20/4, 2014 at 14:4

3

Solved

I'm working on a project that has a Chapter, with each Chapter having a title, content, and order. I'd like to keep the field 'order' named as is, but have the field displayed in a CreateView as so...
Incomer asked 7/11, 2016 at 22:36

4

Solved

I am using Django detailview. initially, I used the URL pattern url(r'^todo/details/(?P<pk>[\d]+)', views.todoDetailView.as_view(), name='detail_todo'), my view is class todoDetailView(D...
Luckin asked 28/9, 2018 at 8:24

2

Solved

How do I declare a variable in Django's Createview, so I can use it from its template? For example I want to use {{ place_slug }} in the template. I pass that from urls.py like below: urls.py: ur...

1

My goal very much resembles to what has been asked in this question but from the perspective of DRF, rather than forms. So basically the question is, how can I get the newly created object in the...
Skyrocket asked 16/4, 2020 at 14:49

5

Solved

I want to overwrite Response class of django rest framework so that response back responsive dictionary contain three parameter message, status and data Hello dears all I try to change Response C...

7

Solved

I have a custom class-based view # myapp/views.py from django.views.generic import * class MyView(DetailView): template_name = 'detail.html' model = MyModel def get_object(self, queryset=None...
Toadinthehole asked 15/7, 2012 at 18:26

3

Solved

I created a class that subclasses ListView and two custom mixins which have implemented a get_context_data function. I wanted to override this function on the child class: from django.views.generi...

2

Solved

I'm writing a test for a Django Rest Framework view following closely the testing documentation Here's my simple test: def test_patient_detail_api_opens(self): factory = APIRequestFactory() vi...

2

Solved

With django generic CreateView I can create a new user account, but how can I login this user automatically after registration using this technique? urls.py ... url( r'^signup/$', SignUpView.as...
Zeitgeist asked 22/10, 2014 at 14:43

3

Solved

So I have two models: Car and Picture. a car may have multiple pictures. Now I want to use a list view to display all the cars along with one picture for each car, can someone tell me how can I do...
Fluoro asked 13/4, 2015 at 5:22

1

I'm learning about the Django Rest Framework. And there are two concepts that from my point of view are almost the same, and they are used in different scenarios. rest_framework mixins I think that...
Guilford asked 7/4, 2019 at 23:22

3

Solved

I'm running Django 1.6.x To extend my user I've added another model storing the data: class UserProfile (models.Model): user = models.ForeignKey(User) height = models.IntegerField(blank=True, ...
Wizard asked 8/2, 2014 at 21:33

4

Solved

I am using Django's class based generic views in a blog application. One of my views displays a list of posts that have a certain tag. I can write this view as a ListView of posts, filtered by tag....
Observe asked 19/3, 2012 at 20:8

1

Solved

i am in django 2 and facing some issues here. Let me give you my files first views.py class home_view(ListView): model = home_blog_model template_name = "home.html" context_object_name = "post...
Winnipegosis asked 25/11, 2018 at 5:12

3

Solved

Let's say I have some Models that inherit from a base class, Animal. I can use generic views and route Cat/12 to a detail view and Dod/10 to the same detail view with a different context. But I wou...
Dagny asked 24/4, 2013 at 18:10

4

Solved

I am new to django (1.2.4). I have created some crud with generic views. But How can I show something like "The student was added successfully" when student is created using django's messaging fram...
Fineable asked 26/1, 2011 at 8:19

2

Solved

I have 2 separate models, Post and Comment. I use DetailView to display Post contents and I want to use a CreateView to display comment creation form on the same page. What is the cleanest way to g...
Despoliation asked 26/12, 2013 at 13:49

5

Solved

These two pieces of code are identical at the first blush: class IndexView(generic.ListView): template_name = 'polls/index.html' context_object_name = 'latest_poll_list' queryset = Poll.active....
Goatskin asked 31/10, 2013 at 13:1

2

Solved

I have a model that uses different validation for its name field depending on whether the object was created by a user or by the system. class Symbol(models.Model): name = models.CharField(_('nam...

2

Solved

I'm currently trying to call a class based Generic view from within another class based generic view and cant seem to do it correctly. Ways I've tried: result = CategoryTypes.as_view() # The same w...
Beadsman asked 31/8, 2011 at 14:55

2

Solved

My views.py of django app is as below, class MemberCreate(generics.CreateAPIView): queryset = members.objects.all() serializer_class = MemberSerializer permission_classes = (permissions.IsAdmin...
Craniate asked 31/8, 2017 at 12:48

3

What is the difference between get_context_data and queryset in Django generic views? They seem to do the same thing?
Griseous asked 29/6, 2017 at 10:51

1

Solved

I have just started messing with class based views and I would like to be able to access variables from the URL inside my class. But I am having difficulties getting this to work. I saw some answer...
Touchmenot asked 17/1, 2017 at 22:44

© 2022 - 2024 — McMap. All rights reserved.