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 6018223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:14:38+00:00 2026-05-23T03:14:38+00:00

I am using classed based views with django 1.3 and am trying to figure

  • 0

I am using classed based views with django 1.3 and am trying to figure out how to create an object without using the form. I do not need any user input to create the object but I am still getting an error message that the template is missing. Below is my current view where I have tried to subclass the form_valid method but its not working. Any help would be appreciated.

class ReviewerCreateView(CreateView):
    model = Reviewer

    def form_valid(self, form):
        self.object = form.save(commit=False)
        self.object.user = self.request.user
        self.object.role = 2
        self.object.save()
        return HttpResponseRedirect(self.get_success_url())
  • 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-05-23T03:14:39+00:00Added an answer on May 23, 2026 at 3:14 am

    A CreateView is a specialized view whose purpose is to display a form on GET and validate the form data and create a new object based on the form data on POST.

    Since you don’t need to display a form and process the form data, a CreateView is not the tool for your job.

    You either need a plain old function-based view, or, if you prefer to use a class-based view, derive from View and override get() or post(). For example, adapting your sample code:

    class ReviewerCreator(View):
        def get(self, request, *args, **kwargs):
             Reviewer(user=request.user, role=2).save()
             return HttpResponseRedirect('/your_success_url/')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could someone please help with reg/auth/auth using class-based generic views? It is clear how
I'm creating custom class based views for a Django project and faced a design
Can I reduce the textbox width without using classes? <input type=text maxlength=5 style=3px/>
Is there any overhead using partial classes in case of memory, performance etc? If
I am trying to add a dynamic Meta attribute to all of my Django
Creating simple app using GAE / Django-nonrel (I don't think the problem is specific
I'm trying to implement chained drop down boxes using the tutorial here . My
I have started learning django and have a problem with INSERT-query using ORM (DB
I am using Django 1.3 with mod_wsgi In my settings.py DISABLE_SYSTEM = False DISABLE_USER_INTERFACE
I'm having trouble figuring out the best approach for an certain application. I'm not

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.