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

reverse for ' with arguments '()' and keyword arguments not found. 1 pattern(s) tried:

I am trying to get a ListView for which get_absolute_url is defined in my template. But it raises an error: Reverse for 'accept_bid' with arguments '()' and keyword arguments '{'bid_id': 16}' not found. 1 pattern(s) tried:…
0
votes
0 answers

How do I use the date_list from Generic Date Views in Django?

I have this function I was using to convert date objects from my blog posts into a dictionary of years and months I can display in a sidebar: def post_dates(self): """Get dictionary of dates for all posts.""" grouped_dates =…
AncientSwordRage
  • 7,086
  • 19
  • 90
  • 173
0
votes
0 answers

Why aren't my Django GenericDateViews displaying my blog posts?

I have been trying to refactor my blog post views form a single custom template/view/url setup to a hopefully better set of Generic Date Views. However this is not working as planned, as my new views aren't picking up the objects. I've tried to read…
0
votes
1 answer

DetailView and templates

Django 1.9.7 Could you help me with three questions about DetailView: Why DetailView doesn't put form into the context whereas CreateView does? I mean it is very cumbersome to write a template where every field is shown separately like…
Michael
  • 4,273
  • 3
  • 40
  • 69
0
votes
0 answers

Posting data from form and validating data using django detailview

I am working in django 1.8 project, and I have a model called company and I have used the generic view to do simple CRUD over this model. I have a detail view, which renders the detail of the company model in a template name called…
shining
  • 1,049
  • 16
  • 31
0
votes
2 answers

DJANGO Generic Views: How to use reverse() in get_absolute_url method?

I'm trying to implement generic editing views as shown here: I started with the CreateView which renders and submits data correctly. However, I am getting an error when I tries to use reverse() to return to the detail view page for the new object.…
Solomon Bothwell
  • 1,004
  • 2
  • 12
  • 21
0
votes
1 answer

Internationalizing a Django class-based generic view (CreateView)?

I am using Django 1.9 class-based generic views, for example CreateView. When I visit the "create" page, some parts are translated (into French in my example), so I know my config and wiring is correct, but the form fields (auto-named by the view)…
dfrankow
  • 20,191
  • 41
  • 152
  • 214
0
votes
1 answer

Redirect from Generic View to Generic View

I am building a page for user registration. I want the customer to enter information step by step, so I want to separate the forms. For example, entering username, password, then go to next page and enter other information. I realize that with…
q2ven
  • 187
  • 9
0
votes
0 answers

How to set a model field based on the current user in a Django CreateView

I have the following view: from django.views.generic.edit import CreateView from news.forms import CreateNewsStoryForm from news.models import NewsStory class CreateNewsStoryView(CreateView): model = NewsStory form_class =…
bigblind
  • 12,539
  • 14
  • 68
  • 123
0
votes
1 answer

Django ListView Page Not Found

So after upgrading to Django 1.9, I have this strange issue with ListViews and url matching. Everything works fine in development, but my views which subclass ListView throw 404s in production (CherryPy/IIS using FORCE_SCRIPT_NAME = '/project'): 404…
BottleZero
  • 893
  • 6
  • 13
0
votes
1 answer

What is the difference between use fields attribute and use a FormClass in Django CreateView?

What is the difference between use: class FooCreateView(CreateView): model = Foo fields = (f,o,o) and class FooCreateView(CreateView): model = Foo form_class = FooForm
arcegk
  • 1,480
  • 12
  • 15
0
votes
1 answer

Django form validation fails if value set using form.instance

I am trying to assign currently logged in user as an attribute to a field of a modelform instance using generic views. I have referred to this SO post and did override post method but it was giving me an error that CreatedBy field was required. Also…
cutteeth
  • 2,148
  • 3
  • 25
  • 45
0
votes
2 answers

How to call GenericModelViews with arguments from another view?

I want to return GenericDeleteView with arguments from another view. I have a view, that gets an pk of an object and I want to delete it using Django generic DeleteView subclass. The problem is that the pk can be of different Models. I have the…
0
votes
1 answer

How to load the template_name for a generic view from the database?

I have a model that has a template_name field and I have this generic view: url(r'^/post/(?P[a-zA-Z0-9_.-]+)$', 'django.views.generic.list_detail.object_detail', { "template_object_name" : "post", 'template_name':…
the_drow
  • 18,571
  • 25
  • 126
  • 193
0
votes
0 answers

How do you get the correct model instance using the PK without using the URL

I am trying to pass the PK of a blog post but I am having difficulty with it. If possible I would like to pass the PK without putting it in the URL. I am trying to let my user edit their posts which are displayed in a list like below: I need to…
ollysmall
  • 633
  • 2
  • 7
  • 13