Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8031653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:10:41+00:00 2026-06-05T01:10:41+00:00

I know this is caused when the view has a code path that doesn’t

  • 0

I know this is caused when the view has a code path that doesn’t return an HttpResponse, obviously. I’m new to django, so this may be completely wrong.

Here’s the FormView code. Do I need to override render_to_response?

class AddAdvertView(FormView):
    form_class = NewAdForm

    def get(self, *args, **kwargs):
            self.campaign = get_object_or_404(Campaign, id__exact = self.kwargs['campaign_id'])

    def post(self, request, *args, **kwargs):
            pass

    def get_form(self, form_class):
            return form_class(initial = {}, campaign = self.campaign)

    def get_success_url(self):
            return self.request.META.get('HTTP_REFERER', None)

    def form_valid(self, form):
            return HttpResponse('form valid')

    def form_invalid(self, form):
            return HttpResponse('form invalid')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T01:10:43+00:00Added an answer on June 5, 2026 at 1:10 am

    This is probably what you want in your get method:

     def get(self, *args, **kwargs):
         campaign = get_object_or_404(Campaign, id=self.kwargs['campaign_id'])
         ctx = self.get_context_data()
         ctx['campaign'] = campaign
         return self.render_to_response(ctx)
    

    If you aren’t doing anything with post, you shouldn’t have a method to override it. Similarly you don’t need to override get_form.

    Class based views are new in django and their documentation isn’t up to par with the other components; hopefully this will change soon. For now, the best place to find out how class based views work is look at what their mixins provide.

    For FormView, the mixins are FormMixin and ProcessFormView

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Sorry, I know that this topic has been covered a bit. I've read the
I know this question has kind-a started religious wars in past and there might
I have an application with a view that has text fields from the top
I don't know if this SO question is of the same problem that I
I know this has been asked a lot on SO, but unfortunately none of
I know this question is probably stoopid. But I just don't want to cause
I'm looking without success (maybe cause i don't know how to call this slider)
Know this might be rather basic, but I been trying to figure out how
I know this is fairly subjective, but I'm diving into testing and learning about
I know this is largely an opinion, but I'm interested if you have one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.