Quantcast

'OneToOneField' object has no attribute 'get' in function-based view

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

'OneToOneField' object has no attribute 'get' in function-based view

Pedro Paulo Palazzo

I am writing a two-part form where I want to pass the object saved in the first part as a OneToOneField for the object in the second part.

In views.py:


def object_entry(request):
    if request.method == 'POST':
        title_form = TitleEntry(request.POST)
        object_form = ObjectEntry(request.POST)
        if title_form.is_valid():
            title = title_form.cleaned_data['title']
            title_type = title_form.cleaned_data['title_type']
            title_lang = title_form.cleaned_data['lang']
            title_translation = title_form.cleaned_data['translation']
            title_currency = title_form.cleaned_data['currency']
            title_level = title_form.cleaned_data['level']
            title_note = title_form.cleaned_data['note']
            title_source = title_form.cleaned_data['source']
            new_title = title_form.save()
            return new_title

        else:
            return render_to_response('objectinfo/objectregister_form.html', {'object_form': object_form, 'title_form': title_form})

        if object_form.is_valid():
            object_form.preferred_title = new_title
            snapshot = object_form.cleaned_data['snapshot']
            work_type = object_form.cleaned_data['work_type']
            source = object_form.cleaned_data['source']
            brief_description = object_form.cleaned_data['brief_description']
            description_source = object_form.cleaned_data['description_source']
            comments = object_form.cleaned_data['comments']
            distinguishing_features = object_form.cleaned_data['distinguishing_features']
            new_object = object_form.save()
            reorg.AccessionNumber.generate(new_object.pk)

            return HttpResponseRedirect('/work/')
            # return HttpResponseRedirect(reverse(description_edit, args=(new_object.pk,)))

        else:
            return render_to_response('objectinfo/objectregister_form.html', {'object_form': object_form, 'title_form': title_form})

    else:
        title_form = TitleEntry()
        object_form = ObjectEntry()
        return render(request, 'objectinfo/objectregister_form.html', {'object_form': object_form, 'title_form': title_form})


And in forms.py:


class
ObjectEntry(ModelForm): class Meta: model = ObjectRegister fields = ['snapshot', 'work_type', 'source', 'brief_description', 'description_source', 'comments', 'distinguishing_features', 'storage_unit', 'normal_unit'] class TitleEntry(ModelForm): class Meta: model = ObjectName fields = ['title', 'title_type', 'lang', 'translation', 'currency', 'level', 'note', 'source']


When submitting the form it returns the error 'ObjectName' object has no attribute 'get'. What would be the correct way to pass new_title as the OneToOneField of object_form.preferred_title?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/90eb2aa6-d802-4972-81ca-284b5bebe052%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 'OneToOneField' object has no attribute 'get' in function-based view

Vijay Khemlani
Can you post the whole stack trace of the error?

There are some things that don't make sense in the view function (for
example returning "new_title" from the view) but they are not related
to your initial error.

On 3/15/17, Pedro Paulo Palazzo <[hidden email]> wrote:

>
>
> I am writing a two-part form where I want to pass the object saved in the
> first part as a OneToOneField for the object in the second part.
>
> In views.py:
>
>
> def object_entry(request):
>     if request.method == 'POST':
>         title_form = TitleEntry(request.POST)
>         object_form = ObjectEntry(request.POST)
>         if title_form.is_valid():
>             title = title_form.cleaned_data['title']
>             title_type = title_form.cleaned_data['title_type']
>             title_lang = title_form.cleaned_data['lang']
>             title_translation = title_form.cleaned_data['translation']
>             title_currency = title_form.cleaned_data['currency']
>             title_level = title_form.cleaned_data['level']
>             title_note = title_form.cleaned_data['note']
>             title_source = title_form.cleaned_data['source']
>             new_title = title_form.save()
>             return new_title
>
>         else:
>             return render_to_response('objectinfo/objectregister_form.html',
> {'object_form': object_form, 'title_form': title_form})
>
>         if object_form.is_valid():
>             object_form.preferred_title = new_title
>             snapshot = object_form.cleaned_data['snapshot']
>             work_type = object_form.cleaned_data['work_type']
>             source = object_form.cleaned_data['source']
>             brief_description =
> object_form.cleaned_data['brief_description']
>             description_source =
> object_form.cleaned_data['description_source']
>             comments = object_form.cleaned_data['comments']
>             distinguishing_features =
> object_form.cleaned_data['distinguishing_features']
>             new_object = object_form.save()
>             reorg.AccessionNumber.generate(new_object.pk)
>
>             return HttpResponseRedirect('/work/')
>             # return HttpResponseRedirect(reverse(description_edit,
> args=(new_object.pk,)))
>
>         else:
>             return render_to_response('objectinfo/objectregister_form.html',
> {'object_form': object_form, 'title_form': title_form})
>
>     else:
>         title_form = TitleEntry()
>         object_form = ObjectEntry()
>         return render(request, 'objectinfo/objectregister_form.html',
> {'object_form': object_form, 'title_form': title_form})
>
>
> And in forms.py:
>
>
> class ObjectEntry(ModelForm):
>     class Meta:
>         model = ObjectRegister
>         fields = ['snapshot', 'work_type', 'source', 'brief_description',
> 'description_source', 'comments', 'distinguishing_features', 'storage_unit',
> 'normal_unit']
>
>  class TitleEntry(ModelForm):
>     class Meta:
>         model = ObjectName
>         fields = ['title', 'title_type', 'lang', 'translation', 'currency',
> 'level', 'note', 'source']
>
>
> When submitting the form it returns the error 'ObjectName' object has no
> attribute 'get'. What would be the correct way to pass new_title as the
> OneToOneField of object_form.preferred_title?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> To post to this group, send email to [hidden email].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/90eb2aa6-d802-4972-81ca-284b5bebe052%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALn3ei2XmJ7mbHWqM2wbw5z6qDWXV2MYp37JUQ9frWfhXDc%3Ddg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 'OneToOneField' object has no attribute 'get' in function-based view

Pedro Paulo Palazzo
Here is the traceback:

Environment:

Request Method: POST
Request URL: http://127.0.0.1:8000/work/add/

Django Version: 1.10.6
Python Version: 3.6.0
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'reversion',
 'historicdate.apps.HistoricdateConfig',
 'place.apps.PlaceConfig',
 'agent.apps.AgentConfig',
 'storageunit.apps.StorageunitConfig',
 'objectinfo.apps.ObjectinfoConfig',
 'reorg.apps.ReorgConfig']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']

Traceback:

File "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  42.             response = get_response(request)

File "/path/to/venv/lib/python3.6/site-packages/django/utils/deprecation.py" in __call__
  138.             response = self.process_response(request, response)

File "/path/to/venv/lib/python3.6/site-packages/django/middleware/clickjacking.py" in process_response
  32.         if response.get('X-Frame-Options') is not None:

Exception Type: AttributeError at /work/add/
Exception Value: 'ObjectName' object has no attribute 'get'


I ended up trying a different approach, splitting these forms into two separate views. I was able to pass the pk of the first (title) form to the second (register) through the URL and to prepopulate the latter's OneToOneField with the correct object. However, when I try to save this form, I get an ObjectDoesNotExist:

ObjectName matching query does not exist.

The traceback for this latter error follows:

Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/work/add/57/register/

Django Version: 1.10.6
Python Version: 3.6.0
Installed Applications:
['django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'reversion',
 'historicdate.apps.HistoricdateConfig',
 'place.apps.PlaceConfig',
 'agent.apps.AgentConfig',
 'storageunit.apps.StorageunitConfig',
 'objectinfo.apps.ObjectinfoConfig',
 'reorg.apps.ReorgConfig']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware']



Traceback:

File "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner
  42.             response = get_response(request)

File "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/path/to/project/objectinfo/views.py" in object_entry
  45.         object_form = ObjectEntry(request.POST, request.FILES)

File "/path/to/project/objectinfo/forms.py" in __init__
  9.         self.fields['preferred_title'].initial = ObjectName.objects.get(pk=objectname_id)

File "/path/to/venv/lib/python3.6/site-packages/django/db/models/manager.py" in manager_method
  85.                 return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/path/to/venv/lib/python3.6/site-packages/django/db/models/query.py" in get
  385.                 self.model._meta.object_name

Exception Type: DoesNotExist at /work/add/57/register/
Exception Value: ObjectName matching query does not exist.



Em quarta-feira, 15 de março de 2017 17:21:43 UTC-3, Vijay Khemlani escreveu:
Can you post the whole stack trace of the error?

There are some things that don't make sense in the view function (for
example returning "new_title" from the view) but they are not related
to your initial error.

On 3/15/17, Pedro Paulo Palazzo <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="jR5YoNiMBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">pedro....@...> wrote:

>
>
> I am writing a two-part form where I want to pass the object saved in the
> first part as a OneToOneField for the object in the second part.
>
> In views.py:
>
>
> def object_entry(request):
>     if request.method == 'POST':
>         title_form = TitleEntry(request.POST)
>         object_form = ObjectEntry(request.POST)
>         if title_form.is_valid():
>             title = title_form.cleaned_data['title']
>             title_type = title_form.cleaned_data['title_type']
>             title_lang = title_form.cleaned_data['lang']
>             title_translation = title_form.cleaned_data['translation']
>             title_currency = title_form.cleaned_data['currency']
>             title_level = title_form.cleaned_data['level']
>             title_note = title_form.cleaned_data['note']
>             title_source = title_form.cleaned_data['source']
>             new_title = title_form.save()
>             return new_title
>
>         else:
>             return render_to_response('objectinfo/objectregister_form.html',
> {'object_form': object_form, 'title_form': title_form})
>
>         if object_form.is_valid():
>             object_form.preferred_title = new_title
>             snapshot = object_form.cleaned_data['snapshot']
>             work_type = object_form.cleaned_data['work_type']
>             source = object_form.cleaned_data['source']
>             brief_description =
> object_form.cleaned_data['brief_description']
>             description_source =
> object_form.cleaned_data['description_source']
>             comments = object_form.cleaned_data['comments']
>             distinguishing_features =
> object_form.cleaned_data['distinguishing_features']
>             new_object = object_form.save()
>             reorg.AccessionNumber.generate(<a href="http://new_object.pk" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fnew_object.pk\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGXslZoFJN-zVEReSYtmHixFvPIuw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fnew_object.pk\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGXslZoFJN-zVEReSYtmHixFvPIuw&#39;;return true;">new_object.pk)
>
>             return HttpResponseRedirect('/work/')
>             # return HttpResponseRedirect(reverse(description_edit,
> args=(<a href="http://new_object.pk" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fnew_object.pk\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGXslZoFJN-zVEReSYtmHixFvPIuw&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fnew_object.pk\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGXslZoFJN-zVEReSYtmHixFvPIuw&#39;;return true;">new_object.pk,)))
>
>         else:
>             return render_to_response('objectinfo/objectregister_form.html',
> {'object_form': object_form, 'title_form': title_form})
>
>     else:
>         title_form = TitleEntry()
>         object_form = ObjectEntry()
>         return render(request, 'objectinfo/objectregister_form.html',
> {'object_form': object_form, 'title_form': title_form})
>
>
> And in forms.py:
>
>
> class ObjectEntry(ModelForm):
>     class Meta:
>         model = ObjectRegister
>         fields = ['snapshot', 'work_type', 'source', 'brief_description',
> 'description_source', 'comments', 'distinguishing_features', 'storage_unit',
> 'normal_unit']
>
>  class TitleEntry(ModelForm):
>     class Meta:
>         model = ObjectName
>         fields = ['title', 'title_type', 'lang', 'translation', 'currency',
> 'level', 'note', 'source']
>
>
> When submitting the form it returns the error 'ObjectName' object has no
> attribute 'get'. What would be the correct way to pass new_title as the
> OneToOneField of object_form.preferred_title?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="jR5YoNiMBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django-users...@googlegroups.com.
> To post to this group, send email to <a href="javascript:" target="_blank" gdf-obfuscated-mailto="jR5YoNiMBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">django...@....
> Visit this group at <a href="https://groups.google.com/group/django-users" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/group/django-users&#39;;return true;">https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> <a href="https://groups.google.com/d/msgid/django-users/90eb2aa6-d802-4972-81ca-284b5bebe052%40googlegroups.com" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/django-users/90eb2aa6-d802-4972-81ca-284b5bebe052%40googlegroups.com&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/django-users/90eb2aa6-d802-4972-81ca-284b5bebe052%40googlegroups.com&#39;;return true;">https://groups.google.com/d/msgid/django-users/90eb2aa6-d802-4972-81ca-284b5bebe052%40googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.
>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0fa9eb4f-b9fb-43cc-8123-8f473c3251d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 'OneToOneField' object has no attribute 'get' in function-based view

Vijay Khemlani
At least I can help with the original problem

Your view function should return an HttpResponse object, but inside
your view you have this

new_title = title_form.save()
return new_title

new_title is an instance of your ObjectName model, that's why Django
crashes when it tries to use it as an HttpResponse object and throws
that error.

I'm not quite sure what are you trying to accomplish in your view.

On 3/15/17, Pedro Paulo Palazzo <[hidden email]> wrote:

> Here is the traceback:
>
> Environment:
> Request Method: POSTRequest URL: http://127.0.0.1:8000/work/add/
> Django Version: 1.10.6Python Version: 3.6.0Installed
> Applications:['django.contrib.admin',
>  'django.contrib.auth',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.messages',
>  'django.contrib.staticfiles',
>  'reversion',
>  'historicdate.apps.HistoricdateConfig',
>  'place.apps.PlaceConfig',
>  'agent.apps.AgentConfig',
>  'storageunit.apps.StorageunitConfig',
>  'objectinfo.apps.ObjectinfoConfig',
>  'reorg.apps.ReorgConfig']Installed
> Middleware:['django.middleware.security.SecurityMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.middleware.common.CommonMiddleware',
>  'django.middleware.csrf.CsrfViewMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>  'django.contrib.messages.middleware.MessageMiddleware',
>  'django.middleware.clickjacking.XFrameOptionsMiddleware']
> Traceback:
> File
> "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/exception.py"
> in inner
>   42.             response = get_response(request)
> File "/path/to/venv/lib/python3.6/site-packages/django/utils/deprecation.py"
> in __call__
>   138.             response = self.process_response(request, response)
> File
> "/path/to/venv/lib/python3.6/site-packages/django/middleware/clickjacking.py"
> in process_response
>   32.         if response.get('X-Frame-Options') is not None:
> Exception Type: AttributeError at /work/add/Exception Value: 'ObjectName'
> object has no attribute 'get'
>
>
>
> I ended up trying a different approach, splitting these forms into two
> separate views. I was able to pass the pk of the first (title) form to the
> second (register) through the URL and to prepopulate the latter's
> OneToOneField with the correct object. However, when I try to save this
> form, I get an ObjectDoesNotExist:
>
> ObjectName matching query does not exist.
>
>
> The traceback for this latter error follows:
>
> Environment:Request Method: POSTRequest URL:
> http://127.0.0.1:8000/work/add/57/register/Django Version: 1.10.6Python
> Version: 3.6.0Installed Applications:['django.contrib.admin',
> 'django.contrib.auth', 'django.contrib.contenttypes',
> 'django.contrib.sessions', 'django.contrib.messages',
> 'django.contrib.staticfiles', 'reversion',
> 'historicdate.apps.HistoricdateConfig', 'place.apps.PlaceConfig',
> 'agent.apps.AgentConfig', 'storageunit.apps.StorageunitConfig',
> 'objectinfo.apps.ObjectinfoConfig', 'reorg.apps.ReorgConfig']Installed
> Middleware:['django.middleware.security.SecurityMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware']Traceback:File
> "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/exception.py"
> in inner  42.             response = get_response(request)File
> "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in
> _get_response  187.                 response =
> self.process_exception_by_middleware(e, request)File
> "/path/to/venv/lib/python3.6/site-packages/django/core/handlers/base.py" in
> _get_response  185.                 response = wrapped_callback(request,
> *callback_args, **callback_kwargs)File
> "/path/to/project/objectinfo/views.py" in object_entry  45.
> object_form = ObjectEntry(request.POST, request.FILES)File
> "/path/to/project/objectinfo/forms.py" in __init__  9.
> self.fields['preferred_title'].initial =
> ObjectName.objects.get(pk=objectname_id)File
> "/path/to/venv/lib/python3.6/site-packages/django/db/models/manager.py" in
> manager_method  85.                 return getattr(self.get_queryset(),
> name)(*args, **kwargs)File
> "/path/to/venv/lib/python3.6/site-packages/django/db/models/query.py" in get
>  385.                 self.model._meta.object_nameException Type:
> DoesNotExist at /work/add/57/register/Exception Value: ObjectName matching
> query does not exist.
>
>
>
>
> Em quarta-feira, 15 de março de 2017 17:21:43 UTC-3, Vijay Khemlani
> escreveu:
>>
>> Can you post the whole stack trace of the error?
>>
>> There are some things that don't make sense in the view function (for
>> example returning "new_title" from the view) but they are not related
>> to your initial error.
>>
>> On 3/15/17, Pedro Paulo Palazzo <[hidden email] <javascript:>>
>> wrote:
>> >
>> >
>> > I am writing a two-part form where I want to pass the object saved in
>> the
>> > first part as a OneToOneField for the object in the second part.
>> >
>> > In views.py:
>> >
>> >
>> > def object_entry(request):
>> >     if request.method == 'POST':
>> >         title_form = TitleEntry(request.POST)
>> >         object_form = ObjectEntry(request.POST)
>> >         if title_form.is_valid():
>> >             title = title_form.cleaned_data['title']
>> >             title_type = title_form.cleaned_data['title_type']
>> >             title_lang = title_form.cleaned_data['lang']
>> >             title_translation = title_form.cleaned_data['translation']
>> >             title_currency = title_form.cleaned_data['currency']
>> >             title_level = title_form.cleaned_data['level']
>> >             title_note = title_form.cleaned_data['note']
>> >             title_source = title_form.cleaned_data['source']
>> >             new_title = title_form.save()
>> >             return new_title
>> >
>> >         else:
>> >             return
>> render_to_response('objectinfo/objectregister_form.html',
>> > {'object_form': object_form, 'title_form': title_form})
>> >
>> >         if object_form.is_valid():
>> >             object_form.preferred_title = new_title
>> >             snapshot = object_form.cleaned_data['snapshot']
>> >             work_type = object_form.cleaned_data['work_type']
>> >             source = object_form.cleaned_data['source']
>> >             brief_description =
>> > object_form.cleaned_data['brief_description']
>> >             description_source =
>> > object_form.cleaned_data['description_source']
>> >             comments = object_form.cleaned_data['comments']
>> >             distinguishing_features =
>> > object_form.cleaned_data['distinguishing_features']
>> >             new_object = object_form.save()
>> >             reorg.AccessionNumber.generate(new_object.pk)
>> >
>> >             return HttpResponseRedirect('/work/')
>> >             # return HttpResponseRedirect(reverse(description_edit,
>> > args=(new_object.pk,)))
>> >
>> >         else:
>> >             return
>> render_to_response('objectinfo/objectregister_form.html',
>> > {'object_form': object_form, 'title_form': title_form})
>> >
>> >     else:
>> >         title_form = TitleEntry()
>> >         object_form = ObjectEntry()
>> >         return render(request, 'objectinfo/objectregister_form.html',
>> > {'object_form': object_form, 'title_form': title_form})
>> >
>> >
>> > And in forms.py:
>> >
>> >
>> > class ObjectEntry(ModelForm):
>> >     class Meta:
>> >         model = ObjectRegister
>> >         fields = ['snapshot', 'work_type', 'source',
>> 'brief_description',
>> > 'description_source', 'comments', 'distinguishing_features',
>> 'storage_unit',
>> > 'normal_unit']
>> >
>> >  class TitleEntry(ModelForm):
>> >     class Meta:
>> >         model = ObjectName
>> >         fields = ['title', 'title_type', 'lang', 'translation',
>> 'currency',
>> > 'level', 'note', 'source']
>> >
>> >
>> > When submitting the form it returns the error 'ObjectName' object has no
>> >
>> > attribute 'get'. What would be the correct way to pass new_title as the
>> >
>> > OneToOneField of object_form.preferred_title?
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Django users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an
>> > email to [hidden email] <javascript:>.
>> > To post to this group, send email to [hidden email]
>> <javascript:>.
>> > Visit this group at https://groups.google.com/group/django-users.
>> > To view this discussion on the web visit
>> >
>> https://groups.google.com/d/msgid/django-users/90eb2aa6-d802-4972-81ca-284b5bebe052%40googlegroups.com.
>>
>>
>> > For more options, visit https://groups.google.com/d/optout.
>> >
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [hidden email].
> To post to this group, send email to [hidden email].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0fa9eb4f-b9fb-43cc-8123-8f473c3251d7%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALn3ei3u9x%3D4DgASq1Avt%3DG7Cq6B-v5-T_nz5Wxrf4%2Bn1bVjMg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Loading...