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
3 answers

Django Generic View Model Filtering

so basically i have this generic view that inherits from ListView and what i want it do to is to take some sort of argument (like a string or "options") and then filter my model depending on those arguments. I've looked for two days and can't seem…
Bolian
  • 41
  • 8
0
votes
1 answer

Django GCBV CreateView, set "localize=False" like form.Forms

So I have this class, CreateView, I use it to add a new location to the model location.model. It describes a certain location with coordinates and a small description. Since I set the I18N settings to True, the decimalField will use comma separated…
0
votes
1 answer

how get a variable from url to form's method - save?

I have urlpattern with id ... url(r'^3/(?P[-\w]+)', Biochemical_analysis_of_blood.as_view(),\ name='biochemical_analysis_view'), ... views.py class Biochemical_analysis_of_blood(CreateView): model = BiochemicalAnalysisOfBlood …
0
votes
1 answer

Django UpdateView: Object to update has no values

I'd like to update an object with generic view updateview. The problem arises when I edit an object. Instead of reaching a prefilled form, I reach a blank form. My template for this: {% extends 'base.html' %} {% block content %}
Texas
  • 559
  • 2
  • 6
  • 18
0
votes
0 answers

Django DeleteView without confirmation

I want to delete an object via DeleteView. my views.py looks like this: class HabitDelete(DeleteView): model = Habit success_url = reverse_lazy('renderOverview') template_name = 'overview/habit_delete_confirm.html' my urls.py looks like this: …
Texas
  • 559
  • 2
  • 6
  • 18
0
votes
1 answer

Django: Set kwargs value for excluded field in generic view

Hi I am trying since yesterday. models.py class Event(models.Model): def get_absolute_url(self): return reverse('events:event-detail', kwargs={'pk': self.pk}) class Kategorie(models.Model): event = models.ForeignKey(Event) sport…
user7084802
0
votes
1 answer

override template_name in listview subclass

I have a BookListView which displays all the books in my library. I have also a subclass of BookListView called BookSearchListView. I am trying to override the template by using the template_name variable. But this produces no effect. views.py class…
McCzajnik
  • 163
  • 1
  • 12
0
votes
1 answer

Issue with Django URL Mapping/DetailView

I am new to Django and have been making a sample project. I have been trying to use Generic Detailview. It seems that url redirection works fine but DetailView can't get primarykey from the url. Main url.py:: urlpatterns = [ url(r'^admin/',…
Abhijeet Panwar
  • 1,837
  • 3
  • 26
  • 48
0
votes
1 answer

How to prevent caching of a Sum?

I'm trying to pass a Sum to my ListView. But if I add more to the DB the Sum does not change until I restart Apache. The new objects are appearing in the List. What am I missing? It seems to get cached for some reason. class…
JasonTS
  • 2,479
  • 4
  • 32
  • 48
0
votes
2 answers

Generic views request handling Django

I'm relative new in Django. I want to use generic views like this : class photogalleryView(generic.ListView): template_name = 'xxx/photogallery.html' model = Foto query = Foto.objects.all() def get_queryset(self): return…
Honza Vacek
  • 33
  • 1
  • 2
  • 7
0
votes
1 answer

Using django generic views

I am getting an error using the deleteview while create and update view are working fine and I want to redirect my deleteview to my index page My codes are:- Views.py- from django.views import generic from django.views.generic.edit import…
0
votes
1 answer

Which request to use to fetch data from database based on some data sent?

I am using django-rest-framework's genericAPIViews I want to send some data from the front end to the backend and depending upon the data sent Django should query a model and return some data to the frontend. The data sent is protected data and thus…
coda
  • 2,188
  • 2
  • 22
  • 26
0
votes
1 answer

Django CreateView cancel with empty fields

I have a CountryCreateView for my Country model and I'm trying to add a cancel button to it. However if there isn't something filled out in every field and I press the cancel button, I get a pop-up that says Please fill out this field. When I press…
user2361174
  • 1,872
  • 4
  • 33
  • 51
0
votes
1 answer

(Django) filter displayed objects using the generic ListView

I want to use the generic django ListView to display all the posts of the logged user through this url: #/users/myposts/ url(r'^myposts/', views.MyPostsView.as_view(), name='myposts'), My Post model is as following: class Post(models.Model): …
A2maridz
  • 341
  • 1
  • 4
  • 11
0
votes
1 answer

Get cookie and set context generic view

I am implementing a duplicate vote checking. I set a cookie in the vote view: # Set duplicate vote cookie. half_year = timedelta(weeks=26) expires = datetime.utcnow() + half_year if cookie and re.match(cookie_pattern, cookie): …
user6216224