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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:19:17+00:00 2026-05-15T20:19:17+00:00

I using Django and a generic view django.views.generic.create_update.create_object I have a model form wich

  • 0

I using Django and a generic view “django.views.generic.create_update.create_object”
I have a model form wich i pass to the generic view:

url(r'^add$', create_object, {'template_name':'tpl.html','form_class':MyModelForm,'post_save_redirect':'/'},name = 'add'),

I need to get current user in my ModelForm.save method..
But i can’t find way to get it, please help me to find convinient way?


class MyModelForm(forms.ModelForm):

class Meta:
    model = MyModel


def save(self,*a,**b):
    MyModel.save(user=request.user) #how can i get here request.user?

In common way the question is – how can i accsess request params in forms passed to generic view.

  • 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-15T20:19:18+00:00Added an answer on May 15, 2026 at 8:19 pm

    thnx this helps) I have some problems this syntax and _meta attr and i finished with this


    def create_object_with_request(request, *args, **kwargs):

    def inject_request(fun):
    
        def helper(*args, **kwargs):
            finst = fun(*args, **kwargs)
            finst.request = request
            return finst
    
        helper._meta = fun._meta
        return helper
    kwargs['form_class'] = inject_request(kwargs['form_class'])
    return create_object(request,*args, **kwargs)
    

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

Sidebar

Related Questions

I'm using the generic view django.contrib.auth.views.password_reset for the password reset form. In principle, it
I'm using django.views.generic.list_detail.object_detail. According to the documentation the view takes the variable object_id. To
I am using django Generic views which straigt way loads the create form. I
Let's say trying to use django.views.generic.create_update.create_object to allow the user to a blog entry
I made in my web a menu using generic_view - simple 'django.views.generic.list_detail.object_list' in urls.py
using django 1.4 I have a model with a datetimefield. I imported django.utils.timezone to
I'm currently working with django generic views and I have a problem I can't
I have been using django to write a rather complicated object-oriented model for a
I have a model using Django-MPTT that also has a field for using a
I am using Django generic View but when i type /book/edit/9/ Then it says

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.