Add support for multiple path converters on urls.path()

2019-08-30 Thread Marco Silva
Hello, I'm on the process of migrating an app to django >2 and walked into this potencial new feature while converting the URLs. Some modeles use a "display" id, like TICKET-2019-002, but it's pk is actually a uuid, so the url would ideally support both. I've created a custom converter to veri

Re: Add support for multiple path converters on urls.path()

2019-09-02 Thread Marco Silva
del = model >>def to_python(self, value): >> return self.model.objects.filter(Q(uuid=value)|Q(display_id=value). >> get() >>def to_url(self,value): >> return str(value) >> >> urls.register_converter(lambda: ModelUUIDConverter(TicketModel), >

Re: Proposal: make Model __unicode__() default to self.name

2017-04-07 Thread Marco Silva
I noticed this on the init def __init__(self, *args, **kwargs): # Alias some things as locals to avoid repeat global lookups cls = self.__class__ maybe you should change it to self.cls?? Try to submit a PR to the open ticket. segunda-feira, 3 de Abril de 2017 às 21:07:47 UTC+1, Kapil Garg escr

Re: Proposal: make Model __unicode__() default to self.name

2017-04-08 Thread Marco Silva
lf.__class__ to self.cls > > Because the methods where class is being used frequently, already store it > in local variable and then make references to local variable. > > So should it really be changed ? > > On Fri, Apr 7, 2017, 6:52 PM Marco Silva > wrote: > >> I

Re: Proposal: make Model __unicode__() default to self.name

2017-04-08 Thread Marco Silva
just saw that __repr__ is now under discusion here https://groups.google.com/forum/#!topic/django-developers/UNKFMg6DO5s sábado, 8 de Abril de 2017 às 17:06:05 UTC+1, Marco Silva escreveu: > > I have no idea what is the best way, just say that comment. this is the > original PR

Re: Making __repr__ safe by default

2017-04-08 Thread Marco Silva
going in the python docs we find this > If at all possible, this should look like a valid Python expression that > could be used to recreate an object with the same value (given an > appropriate environment). so maybe something that returned ModelName(field1=value1, field2=value2 ...) where fi