The short of it is that you should probably subclass the picklefield to add some new validation (basically is_integer_two_tuple_list), and write a custom widget for it that does what you want on the html side. The long of it needs not being written from a phone
-----Mensaje original----- De: Alphydan Enviados: 24/10/2012 19:58:29 Asunto: Re: Displaying a custom field (PickledObjectField) in the admin Hi Tomas & John, Thank you for your reply. Basically I'm trying to save curves which I chose to format as: [[0,0],[1,0],[2,1],[3,1], ... ,[40,0]] To see what I tried before (models, etc) you can see the stackoverflow question<http://stackoverflow.com/questions/13034922/storing-a-curve-in-a-django-model-as-manytomany>I asked previously. Some people there suggested the django-picklefield so I implemented it but couldn't get the admin to work. Unfortunately I would eventually need users to put in numbers in a template. For the moment I'm just saving a TextField and doing some pretty coarse and inelegant validation + assuming we enter the curves in the admin. def save(self, *args, **kwargs): pc = self.my_power_curve if pc[0]!='[': pc = 'error. no initial [ --- ' + pc self.my_power_curve = pc elif pc[-1] != ']': pc = 'error. no final ] --- ' + pc self.my_power_curve = pc elif pc.count('[') != 42 or pc.count(']') !=42: pc = 'error. 41 pairs [,] are required or too many brackets --- ' + pc self.my_power_curve = pc elif len(pc)>362: pc = 'error. too many items --- ' + pc self.my_power_curve = pc elif pc.count('(') != 0 or pc.count(')') != 0: pc = 'error. only "[" and "]" brackets allowed --- ' + pc self.my_power_curve = pc else: pass return super(SomeClass, self).save(*args, **kwargs) Ideally I would create form with say 41 little fields: value 1 = [ ] value 2 = [ ] value 3 = [ ] ... value 41 = [ ] and when the users completes *some of them*, I save it as a string: "[[0,0],[1,1],[2,3],[10,20],[20,20],[40,0]]" Eventually I want to retrieve them and calculate things (like area under the curve or make a graph). Any ideas are appreciated, Thank you, Alvaro On Wednesday, 24 October 2012 20:14:16 UTC+1, Tomas Neme wrote: > > Just by the way, I'm looking at django-picklefield code and README > https://github.com/gintas/django-picklefield and it says NOTHING about > a widget, or an admin representation, so.. maybe it's not DESIGNED to > be shown on the admin? it'd make sense, too, since it's.. well, it can > be ANYTHING.... > > On Wed, Oct 24, 2012 at 3:03 PM, Tomas Neme <lacry...@gmail.com<javascript:>> > wrote: > > maybe restate the problem, give some more code, show your models, and > > your admin files, and someone may be able to help a little > > > > -- > > "The whole of Japan is pure invention. There is no such country, there > > are no such people" --Oscar Wilde > > > > |_|0|_| > > |_|_|0| > > |0|0|0| > > > > (\__/) > > (='.'=)This is Bunny. Copy and paste bunny > > (")_(") to help him gain world domination. > > > > -- > "The whole of Japan is pure invention. There is no such country, there > are no such people" --Oscar Wilde > > |_|0|_| > |_|_|0| > |0|0|0| > > (\__/) > (='.'=)This is Bunny. Copy and paste bunny > (")_(") to help him gain world domination. > -- 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/-/6RtZPEgjgFsJ. 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.