Python Forum
Question on returning methods in a class
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question on returning methods in a class
#3
class Board(models.Model):
    category = models.CharField(max_length=20, unique=True)
    description = models.CharField(max_length=100)
 
    def __str__(self):
        return self.category
Using this as example, if you want to return a self.catagory you'll need to define it with self. above.

Then if you want access to it I think this is the way, but instead of using Board use the instance name.

what_you_want = Board._str_()
Reply


Messages In This Thread
RE: Question on returning methods in a class - by michael1789 - Feb-03-2020, 06:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Click on unusual class button using mechanize Ask Question Coto 1 3,882 Feb-18-2018, 07:27 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020