from __future__ import unicode_literals

from django.core.urlresolvers import reverse
from django.db import models
import generic_scaffold

class Book(models.Model):
    title = models.CharField(max_length=128)
    author = models.CharField(max_length=128)
    category = models.CharField(max_length=32)

    def get_absolute_url(self):
        return reverse(self.detail_url_name, args=[self.id])

from __future__ import unicode_literals

try:
    from django.core.urlresolvers import reverse
except ModuleNotFoundError:
    from django.urls import reverse

from django.db import models
import generic_scaffold

class Book(models.Model):
    title = models.CharField(max_length=128)
    author = models.CharField(max_length=128)
    category = models.CharField(max_length=32)

    def get_absolute_url(self):
        return reverse(self.detail_url_name, args=[self.id])

    def __str__(self):
        return '{0} {1} {2}'.format(self.title, self.author, self.category)

Add support for django 2 to example project
Add support for django 2 to example project

  from __future__ import unicode_literals
  
+ try:
- from django.core.urlresolvers import reverse
+     from django.core.urlresolvers import reverse
+ except ModuleNotFoundError:
+     from django.urls import reverse
+ 
  from django.db import models
  import generic_scaffold
  
  class Book(models.Model):
      title = models.CharField(max_length=128)
      author = models.CharField(max_length=128)
      category = models.CharField(max_length=32)
  
      def get_absolute_url(self):
          return reverse(self.detail_url_name, args=[self.id])
  
+     def __str__(self):
+         return '{0} {1} {2}'.format(self.title, self.author, self.category)
+ 
Add support for django 2 to example project
## Code Before:
from __future__ import unicode_literals

from django.core.urlresolvers import reverse
from django.db import models
import generic_scaffold

class Book(models.Model):
    title = models.CharField(max_length=128)
    author = models.CharField(max_length=128)
    category = models.CharField(max_length=32)

    def get_absolute_url(self):
        return reverse(self.detail_url_name, args=[self.id])

## Instruction:
Add support for django 2 to example project
## Code After:
from __future__ import unicode_literals

try:
    from django.core.urlresolvers import reverse
except ModuleNotFoundError:
    from django.urls import reverse

from django.db import models
import generic_scaffold

class Book(models.Model):
    title = models.CharField(max_length=128)
    author = models.CharField(max_length=128)
    category = models.CharField(max_length=32)

    def get_absolute_url(self):
        return reverse(self.detail_url_name, args=[self.id])

    def __str__(self):
        return '{0} {1} {2}'.format(self.title, self.author, self.category)
