Wednesday, February 28, 2018

Re: Trying to create a CBV that allows user to copy a record

Use the get_inital method.

    def get_initial(self):
        initial = super(MyCreateView, self).get_initial()
        initial['name'] = 'Testing'
        return initial

Dylan


On Wed, Feb 28, 2018 at 9:42 AM, Alexander Joseph <alexander.v.joseph@gmail.com> wrote:
I'd like to create a CBV to allow users to copy a record, except for item specific information. - I'm making a fixed assets app and if there are 2 of the same laptop I'd like the user to be able to make one record in the database, then copy it minus the serial number and asset tag number which would be the only info the user would have to fill in to copy that laptop.

Is there a way to do this by modifying the CreateView somehow? Thanks

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/e4c25ff6-9e6e-4e5d-898a-f6d977f9badc%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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/CAHtg44ArLW5ZnWOTDZioO-YUm3vaOAfA0NDKn4U6dfLzmwWxhQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment