thanks..no tabs for sure
On May 22, 6:40 pm, Karen Tracey <[email protected]> wrote:
> On Fri, May 22, 2009 at 8:11 AM, vishy <[email protected]> wrote:
>
> > Hi,
> > I am newbie at Django.I have model with a custom method.In view I am
> > retrieving a single object.See below --
> > My model
> > class Problem(models.Model):
> > problem = models.CharField(max_length=100)
> > solution=models.CharField(max_length=500)
> > def __unicode__(self):
> > return self.problem
> > def retrieve_rankdata(self):
> > return self.problem.split()[0].split('/')
>
> If this is an actual cut and paste: your retrieve_rankdata is not indented
> properly here. The 'def' needs to line up exactly with the other fields and
> methods defined in Problem. It would be better form also to make its
> contents indented a consistent amount rather than having it be so much more
> dramatically indented than everything else.
>
> > in view
> > I am doing this
> > def show(request):
> > problem = Problem.objects.all()[0]
> > t1=problem.retrieve_rankdata()
> > But, I am getting this error
> > 'Problem' object has no attribute 'retrieve_rankdata'
>
> > What am I doing wrong?
>
> Fix the indentation and I expect the problem will go away. Also, be careful
> not to mix tabs and spaces, that will also lead to difficulties in Python.
> Best to stick with spaces and never use tabs.
>
> Karen
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---