Karen Tracey escribió: > On Fri, Apr 25, 2008 at 8:02 AM, Matias Surdi <[EMAIL PROTECTED] > <mailto:[EMAIL PROTECTED]>> wrote: > > > Matias Surdi escribió: > > Sorry, there was an error in the previous message: > > > > > > With the following model: > > > > class Candidate(models.Model): > > name = models.CharField(max_length=100,unique=True) > > file = > > models.FileField(upload_to="curriculums/%Y/%m/%d",max_length=300) > > > > def _get_FIELD_url(self,field): > > return "http://www.google.es" > > if getattr(self, field.attname): # value is not blank > > import urlparse > > return urlparse.urljoin(settings.MEDIA_URL, > getattr(self, > > field.attname)).replace('\\', '/') > > return '' > > > > > > when I do object.get_file_url(), http://www.google.es is returned, as > > expected > > > > but with the following one: > > > > class Candidate(models.Model): > > name = models.CharField(max_length=100,unique=True) > > curriculum = > > models.FileField(upload_to="curriculums/%Y/%m/%d",max_length=300) > > > > def _get_FIELD_url(self,field): > > return "http://www.google.es" > > if getattr(self, field.attname): # value is not blank > > import urlparse > > return urlparse.urljoin(settings.MEDIA_URL, > getattr(self, > > field.attname)).replace('\\', '/') > > return '' > > > > when I do object.get_cirriculum_url(), I don't get the same > result than > > with > > the first one. > > > > > Well, what result do you get? Why not tell us instead of making us guess? > > Unless it's a typo. one problem is you have is you try to get the > 'cirriculum' url but you named the field 'curriculum'. > > (I'm also wondering why you are overriding _get_FIELD_url at all, since > it seems pretty hackish, but I guess that's beside the point.) > > > > > The only difference is the field name. > > > > am I missing something here? what could be happening? > > > > NOTE: Database is destroyed/recreated on each test. > > > > Thanks. > > > > > > > > > > > I think I'm isolating the problem, I think it's related to the field's > name size... when it's longer than 8 character, the problem appears. > > > That's surprising, since there's nothing in Django that has any > dependence on field name length here. > > Karen > > >
Despite the typo, I'm still having the same problem. What I want to do, is not to have a "public" download url.... I want to check user's permissions before a download is started. So, I want to change the behaviour of get_xxxx_url so that it returns a custom view instead of the public url. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

