Re: newbie needs to copy a record in admin to a new record
Thank you [code] def make_copy(modeladmin, request, queryset): for obj in queryset: obj.pk = None obj.object_name = "dup" obj.save() make_copy.short_description = "Copy selected records" [/code] On Friday, January 11, 2013 10:53:02 AM UTC-5, Brad Pitcher wrote: > > I think what should work well for your use case is an admin action: > > https://docs.djangoproject.com/en/1.4/ref/contrib/admin/actions/ > > You can write code for a copy action in admin.py. This will add a "copy" > item to the dropdown in the list view, so you can select any number of list > items and copy them. > > - > Brad Pitcher > Software Developer > (702)723-8255 > > > On Fri, Jan 11, 2013 at 7:06 AM, froccowrote: > >> Hello, >> >> I am just learning django and want to allow a user in admin to copy a >> record from the list to create a new record and make changes. >> This will prevent having to type similar data. >> >> How do I add a link to the admin list? >> where do I put code to dup the record? >> >> Thank you >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/django-users/-/odBD_lyCqmsJ. >> To post to this group, send email to django...@googlegroups.com >> . >> To unsubscribe from this group, send email to >> django-users...@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 view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/APP6hej_yGgJ. 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.
Re: newbie needs to copy a record in admin to a new record
I think what should work well for your use case is an admin action: https://docs.djangoproject.com/en/1.4/ref/contrib/admin/actions/ You can write code for a copy action in admin.py. This will add a "copy" item to the dropdown in the list view, so you can select any number of list items and copy them. - Brad Pitcher Software Developer (702)723-8255 On Fri, Jan 11, 2013 at 7:06 AM, froccowrote: > Hello, > > I am just learning django and want to allow a user in admin to copy a > record from the list to create a new record and make changes. > This will prevent having to type similar data. > > How do I add a link to the admin list? > where do I put code to dup the record? > > Thank you > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/odBD_lyCqmsJ. > 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.
newbie needs to copy a record in admin to a new record
Hello, I am just learning django and want to allow a user in admin to copy a record from the list to create a new record and make changes. This will prevent having to type similar data. How do I add a link to the admin list? where do I put code to dup the record? Thank you -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/odBD_lyCqmsJ. 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.