# -*- coding: UTF-8 -*-
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.translation import ugettext_lazy as _


class GenericLink(models.Model):
    """
    Relates an object with an url and its data
    """

    content_type = models.ForeignKey(ContentType)
    object_id = models.PositiveIntegerField(db_index=True)
    content_object = generic.GenericForeignKey()

    url = models.URLField()
    title = models.CharField(max_length=200)
    description = models.TextField(max_length=1000, null=True, blank=True)

    user = models.ForeignKey("auth.User", null=True, blank=True)
    created_at = models.DateTimeField(auto_now_add=True, db_index=True)

    is_external = models.BooleanField(default=True, db_index=True)

    class Meta:
        ordering = ("-created_at", )
        verbose_name = _("Generic Link")
        verbose_name_plural = _("Generic Links")

    def __unicode__(self):
        return self.url

@@ -17,16 +17,76 @@
 F-8 -*-%0A
+from django import VERSION%0Afrom django.conf import settings%0A
 from dja
@@ -125,16 +125,16 @@
 generic%0A
-
 from dja
@@ -271,16 +271,233 @@
  as _%0A%0A%0A
+def get_user_model_fk_ref():%0A    %22%22%22Get user model depending on Django version.%22%22%22%0A    ver = VERSION%0A%0A    if ver%5B0%5D %3E= 1 and ver%5B1%5D %3E= 5:%0A        return settings.AUTH_USER_MODEL%0A    else:%0A        return 'auth.User'%0A%0A%0A
 class Ge
@@ -926,19 +926,31 @@
 Key(
-%22auth.User%22
+get_user_model_fk_ref()
 , nu

Update for custom user model support