Let's say I have a model called 'Dogs'. Users can create instances of Dogs. Let's say we have a user called User1. I have 2 questions:
-- 1. When User1 creates an instance of Dogs, how do I automatically assign that instance to User1? I tried using a model field like this but it doesn't pick the user automatically:
user = models.ForeignKey(User, unique=False)
2. After the instance has been created, how do I make the instance only editable and removable by the user who made it? Basically, if User1 creates an instance of Dogs, only User1 can edit and delete that instance.
Thanks.
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@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/dedbfe8b-1013-4844-b142-1e8615a1ef9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment