0

Trying to work my way through a Django tutorial, and can't seem to get past this syntax error when I implement a new method:

class Album(models.Model):
    artist = models.CharField(max_length = 250)
    album_title = models.CharField(max_length = 500)
    genre = models.CharField(max_length = 100)
    album_logo = models.CharField(max_length = 1000)


    def__str__(self):
        return self.album_title + ' - ' + self.artist


class Song(models.Model):
    album = models.ForeignKey(Album, on_delete=models.CASCADE)
    file_type = models.CharField(max_length = 10)
    song_title = models.CharField(max_length = 250)

Whenever I run it, I get a syntax error at def_str_(self):

I've checked all of the indents to make sure the spaces are consistent, and I've tried the same method using only spaces and only tabs and neither work. Any thoughts?

1 Answer 1

1

You are missing a space between def (a keyword) and __str__ which is the name of the method you are defining.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.