--
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...@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/8f31afb0-2a9d-49ef-94b4-213aef140cf2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
class CreateDog(CreateView):
model = Dog
fields = ('name', 'bday', 'owner')
template_name = 'animals/dog_create.html'
class CreateCat(CreateView):
model = Cat
fields = ('name', 'bday', 'owner')
template_name = 'animals/cat_create.html'
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...@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/340fa5fd-1475-4355-821c-82404b71b6bb%40googlegroups.com.
Will try it now.Quesion about the on_delete=models.CASCADE, does this mean that if I delete the pet (dog or cat) it will delete the owner who owns them?
On Sun, Jan 28, 2018 at 1:11 PM, Akhil Lawrence <akhilp...@gmail.com> wrote:
Your create view do not accept owner as a input and according to your models, owner can be null. That's the problem. Include owner to your create view fields as shown below. Also you may consider making owner mandatory as mentioned in my previous response.
class CreateDog(CreateView):
model = Dog
fields = ('name', 'bday', 'owner')
template_name = 'animals/dog_create.html'
class CreateCat(CreateView):
model = Cat
fields = ('name', 'bday', 'owner')
template_name = 'animals/cat_create.html'
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...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
When I added the owner field, it doesn't have any value though the user is already registered.how do i make it mandatory in createview?owner = Owner.objects.create_user(username="blah", password="blah", email="bl...@blah.com")dog = Dog(name="mydog", bday=datetime.today(), owner=owner).save()
On Sun, Jan 28, 2018 at 1:13 PM, tango ward <tango...@gmail.com> wrote:
Will try it now.Quesion about the on_delete=models.CASCADE, does this mean that if I delete the pet (dog or cat) it will delete the owner who owns them?
On Sun, Jan 28, 2018 at 1:11 PM, Akhil Lawrence <akhilp...@gmail.com> wrote:
Your create view do not accept owner as a input and according to your models, owner can be null. That's the problem. Include owner to your create view fields as shown below. Also you may consider making owner mandatory as mentioned in my previous response.
class CreateDog(CreateView):
model = Dog
fields = ('name', 'bday', 'owner')
template_name = 'animals/dog_create.html'
class CreateCat(CreateView):
model = Cat
fields = ('name', 'bday', 'owner')
template_name = 'animals/cat_create.html'
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...@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 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...@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/09d7c9ca-7dab-4787-94d9-09b3a1bc682a%40googlegroups.com.
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...@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/d5f91e94-bd91-47d4-9a26-bfbd56283f00%40googlegroups.com.
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...@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/f8be9ac2-1738-4674-83b6-8baa2de8b446%40googlegroups.com.
"<SimpleLazyObject: <User: owner2>>": "Dog.owner" must be a "User" instance."
Really appreciate you're help/suggestions. My first time to mess around with CRUD with user registration, login, logout.
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...@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/a3c4fa5c-9942-4570-a518-003fab4cbc3d%40googlegroups.com.
Cannot assign "<SimpleLazyObject: <django.contrib.auth.models.AnonymousUser object at 0x7fe3fa28fe48>>": "Dog.owner" must be a "User" instance.models.py
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...@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/fba65b1a-7dd1-4e2f-818e-0d75cbce5c11%40googlegroups.com.
The takeaway from the above error is AnonymousUser
This means you are not logged into the system. By default self.request.user will be an instance of AnonymousUser,
the moment you login it becomes User instance
Make sure you login before hitting this code
Thanks.
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...@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/3737bd26-2740-45ef-9bb5-cd8c4a2787e6%40googlegroups.com.
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...@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/29376a61-8633-4c97-8cfa-8988c65bc212%40googlegroups.com.