from django.db import models
from django.core.urlresolvers import reverse
from django_summernote import models as summer_model
from django_summernote import fields as summer_fields


class Board(models.Model):
    def get_absolute_url(self):
        return reverse('board:post_list', args=[self.id])

    slug = models.TextField(default='', unique=True)
    name = models.TextField(default='')


class Post(models.Model):
    def get_absolute_url(self):
        return reverse('board:view_post', args=[self.id])

    title = models.TextField(default='')
    content = models.TextField(default='')
    board = models.ForeignKey(Board, null=True)

    class Meta:
        index_together = [
            ["title", "content"],
        ]


class SummerNote(summer_model.Attachment):
    summer_field = summer_fields.SummernoteTextField(default='')


class Comment(models.Model):
    content = models.TextField(default='')
    post = models.ForeignKey(Post, null=True)

from django.db import models
from django.core.urlresolvers import reverse
from django_summernote import models as summer_model
from django_summernote import fields as summer_fields


class Board(models.Model):
    def get_absolute_url(self):
        return reverse('board:post_list', args=[self.id])

    slug = models.TextField(default='', unique=True)
    name = models.TextField(default='')


class Post(models.Model):
    def get_absolute_url(self):
        return reverse('board:view_post', args=[self.board.slug, self.id])

    title = models.TextField(default='')
    content = models.TextField(default='')
    board = models.ForeignKey(Board, null=True)

    class Meta:
        index_together = [
            ["title", "content"],
        ]


class SummerNote(summer_model.Attachment):
    summer_field = summer_fields.SummernoteTextField(default='')


class Comment(models.Model):
    content = models.TextField(default='')
    post = models.ForeignKey(Post, null=True)

Fix 'get_absolute_url()' refer to url
Fix 'get_absolute_url()' refer to url

  from django.db import models
  from django.core.urlresolvers import reverse
  from django_summernote import models as summer_model
  from django_summernote import fields as summer_fields
  
  
  class Board(models.Model):
      def get_absolute_url(self):
          return reverse('board:post_list', args=[self.id])
  
      slug = models.TextField(default='', unique=True)
      name = models.TextField(default='')
  
  
  class Post(models.Model):
      def get_absolute_url(self):
-         return reverse('board:view_post', args=[self.id])
+         return reverse('board:view_post', args=[self.board.slug, self.id])
  
      title = models.TextField(default='')
      content = models.TextField(default='')
      board = models.ForeignKey(Board, null=True)
  
      class Meta:
          index_together = [
              ["title", "content"],
          ]
  
  
  class SummerNote(summer_model.Attachment):
      summer_field = summer_fields.SummernoteTextField(default='')
  
  
  class Comment(models.Model):
      content = models.TextField(default='')
      post = models.ForeignKey(Post, null=True)
  
Fix 'get_absolute_url()' refer to url
## Code Before:
from django.db import models
from django.core.urlresolvers import reverse
from django_summernote import models as summer_model
from django_summernote import fields as summer_fields


class Board(models.Model):
    def get_absolute_url(self):
        return reverse('board:post_list', args=[self.id])

    slug = models.TextField(default='', unique=True)
    name = models.TextField(default='')


class Post(models.Model):
    def get_absolute_url(self):
        return reverse('board:view_post', args=[self.id])

    title = models.TextField(default='')
    content = models.TextField(default='')
    board = models.ForeignKey(Board, null=True)

    class Meta:
        index_together = [
            ["title", "content"],
        ]


class SummerNote(summer_model.Attachment):
    summer_field = summer_fields.SummernoteTextField(default='')


class Comment(models.Model):
    content = models.TextField(default='')
    post = models.ForeignKey(Post, null=True)

## Instruction:
Fix 'get_absolute_url()' refer to url
## Code After:
from django.db import models
from django.core.urlresolvers import reverse
from django_summernote import models as summer_model
from django_summernote import fields as summer_fields


class Board(models.Model):
    def get_absolute_url(self):
        return reverse('board:post_list', args=[self.id])

    slug = models.TextField(default='', unique=True)
    name = models.TextField(default='')


class Post(models.Model):
    def get_absolute_url(self):
        return reverse('board:view_post', args=[self.board.slug, self.id])

    title = models.TextField(default='')
    content = models.TextField(default='')
    board = models.ForeignKey(Board, null=True)

    class Meta:
        index_together = [
            ["title", "content"],
        ]


class SummerNote(summer_model.Attachment):
    summer_field = summer_fields.SummernoteTextField(default='')


class Comment(models.Model):
    content = models.TextField(default='')
    post = models.ForeignKey(Post, null=True)
