django-class-based-views are Django views that are represented as classes. These allow you to structure your views and reuse code by harnessing inheritance and mixins.
0
votes
0answers
5 views
Django class based views - UpdateView with two model forms - one submit
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 ...
0
votes
0answers
21 views
how to get initial parameters during updating a form in Django with TemplateView
I have the following class based TemplateView, I want my TemplateView to be like UpdateView.But I am not very sure where to set the form with the instance parameters.
I try it in get_context_data ...
0
votes
0answers
16 views
Using tiny templates in many templates : custom tags or class-based views?
I was recently figured out what was the best way to include tiny pieces of templates that can be repetitive and that we can find on many pages. I call them "widget" not in a Django way (a widget being ...
0
votes
1answer
31 views
Having trouble handling AJAX with Django Class Based View
I've been trying to switch my codes from Django function based view to class based view, but I'm having trouble understanding how to handle AJAX in Django CBV.
For example, suppose that I have this ...
0
votes
2answers
25 views
Using ClassBasedViews I want to retrieve records from my database in Django based on the user's email, which is stored in a session
For the past 2hrs i've been trying to accomplish the following in Django 1.5:
I want to retrieve records from my database based on the user's email, which is stored in a session. Here are my ideal ...
0
votes
2answers
35 views
How do I use UpdateView?
I have two, presumably related, problems with UpdateView. First, it is not updating the user but creating a new user object. Second, I cannot restrict the fields displayed in the form.
Here is my ...
3
votes
1answer
33 views
Using get_success_url on a DeleteView when relevant data has been removed
In a Django application working with recipes I have subclassed DeleteView to create my IngredientListItemDeleteView, but I would like the result of get_success_url to depend on a property of the item ...
0
votes
1answer
23 views
Django ModelView's “fields” attribute not working?
I'm practicing with Django's Class-Based-View.
While practicing with the generic CreateView, I have trouble understanding why my "fields" attributeis not working... I'm trying to construct a Post ...
0
votes
3answers
43 views
Django's get_context_data function not working?
I'm practicing with Django's Class Based View.
It seems like my overridden get_context_data function is not working properly, but I have no idea what is wrong :(
My code:
urls.py
...
0
votes
2answers
36 views
Django CreateView gives an error “needs to have a value for field ”…“ before this many-to-many relationship can be used.”
I'm practicing with Django's FormViews.
In this app, I'm creating a PostCreate view that creates a blog post.
Here are my codes:
models.py
class Post(models.Model):
user = ...
1
vote
2answers
52 views
Django CreateView is not saving object
I'm practicing django Class-Based-View with a basic blog application.
For some reason, however, the CreateView for my Post model is not saving the post inside the database.
models.py
class ...
0
votes
3answers
50 views
Django class-based views function execution order
I'm converting some django views to be class based, and so far loving the flexibility.
Most of my views subclass from a parent view ClubView. Each subclassed view that needs to handle a post() method ...
1
vote
2answers
45 views
How to add a cancel button to DeleteView in django
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 ...
1
vote
1answer
31 views
'UpdateView with a ModelForm as form_class'-issue
The code I would like to get is for a page that has a simple form of one field to change a user's email address using an UpdateView.
Sounds simple, but the difficulty is that I want the URL mapping ...
0
votes
1answer
35 views
Why does UpdateView need to have model/queryset/get_queryset defined when using form_class as opposed to CreateView?
Works like a charm:
MyCreateView(CreateView):
template_name = "my_template_name"
form_class = MyModelForm
success_url = "/success/"
But the following doesn't:
MyUpdateView(UpdateView):
...