Hey, Thanks Karen for the reply. I have been trying many things on this form and trying to save both the models data using one form in a single instance. I did try the commit=False method too but it gave an error which i couldnt figure out. Everytime i try doing something new an unknown error/exception pops up that too in some random file and location :(.
This is the traceback which i got now after changing code Environment: Request Method: POST Request URL: http://127.0.0.1:8000/cd/registration/register/ Django Version: 1.3 Python Version: 2.7.1 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'registration'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.csrf.CsrfResponseMiddleware') Traceback: File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response 111. response = callback(request, *callback_args, **callback_kwargs) File "C:\Users\pradeep\Desktop\cd\registration\views.py" in register 23. return direct_to_template('success.html',{}) File "C:\Python27\lib\site-packages\django\views\generic\simple.py" in direct_to_template 26. c = RequestContext(request, dictionary) File "C:\Python27\lib\site-packages\django\template\context.py" in __init__ 177. self.update(processor(request)) File "C:\Python27\lib\site-packages\django\core\context_processors.py" in debug 53. if settings.DEBUG and request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS: Exception Type: AttributeError at /cd/registration/register/ Exception Value: 'str' object has no attribute 'META' On Sat, Jun 25, 2011 at 11:04 PM, Karen Tracey <kmtra...@gmail.com> wrote: > On Sat, Jun 25, 2011 at 1:00 PM, CareerDhaba tech <t...@careerdhaba.com>wrote: > >> The user model is getting saved with username and password but the >> userprofile isn;t :( > > > That is a somewhat misleading description of the problem since the code as > you have posted it would not just fail to save the userprofile it would > raise an exception on the attempt to pass user to RegForm, since RegForm as > you have shown it is not expecting user as a keyword argument. > > The right way to handle saving model forms which have explicitly excluded > necessary data is described here: > https://docs.djangoproject.com/en/1.3/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form > > In this case you would want to save the originally-created RegForm instance > uprofile with comit=False, then set the user attribute to the user returned > by the other form save, then save the user profile instance: > > up = uprofile.save(commit=False) > up.user = userid > up.save() > > Karen > -- > http://tracey.org/kmt/ > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.