Setting default foreign key value of type UUID

50 views
Skip to first unread message

Dragan Mestrovik

unread,
Feb 16, 2018, 4:08:55 PM2/16/18
to Django users
Hi,

I am getting issue with setting default foreign key value of type UUID. My models are

import uuid
from django.db import models

# Create your models here.
class Provider(models.Model):
  id = models.UUIDField(primary_key = True, default = uuid.uuid4, editable = False)
  providerName = models.CharField(max_length = 200)
  providerUrl = models.URLField(max_length = 500)
  Email = models.EmailField()
  Password = models.CharField(max_length = 200)

class Course(models.Model):
  id = models.UUIDField(primary_key = True, default = uuid.uuid4, editable = False)
  providerID = models.ForeignKey(Provider, on_delete = models.SET_DEFAULT, default = uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')) #6fa459ea-ee8a-3ca4-894e-db77e160355e
  courseProviderID = models.CharField(max_length = 50)
  courseName = models.CharField(max_length = 200)
  authorName = models.CharField(max_length = 200)
  courseUrl = models.URLField(max_length = 500)
  courseSummary = models.TextField()
  courseCategory = models.CharField(max_length = 200)
  isDownloaded = models.BooleanField(default = False)

Vinicius Assef

unread,
Feb 19, 2018, 7:08:31 PM2/19/18
to django...@googlegroups.com
What's the problem?
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/3b41e4f4-1948-494e-ac31-5214c4c10684%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages