from django.db import models


class Surprise(models.Model):
    link = models.URLField(max_length=500)
    description = models.TextField(max_length=1000)

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


class Surprise(models.Model):
    link = models.URLField(max_length=500)
    description = models.TextField(max_length=1000)

    def get_absolute_url(self):
        return reverse('surprise-detail', kwargs={"pk": self.id})

Add absolute URL for Surprises
Add absolute URL for Surprises

This allows the CreateView to work correctly

+ from django.core.urlresolvers import reverse
  from django.db import models
  
  
  class Surprise(models.Model):
      link = models.URLField(max_length=500)
      description = models.TextField(max_length=1000)
  
+     def get_absolute_url(self):
+         return reverse('surprise-detail', kwargs={"pk": self.id})
+ 
Add absolute URL for Surprises
## Code Before:
from django.db import models


class Surprise(models.Model):
    link = models.URLField(max_length=500)
    description = models.TextField(max_length=1000)

## Instruction:
Add absolute URL for Surprises
## Code After:
from django.core.urlresolvers import reverse
from django.db import models


class Surprise(models.Model):
    link = models.URLField(max_length=500)
    description = models.TextField(max_length=1000)

    def get_absolute_url(self):
        return reverse('surprise-detail', kwargs={"pk": self.id})
