Sunday, September 23, 2018

Re: Error at OneToOneField in models while creating new models class

First you have to change your model name Class names starts with uppercase...

My friend.. you are not making migrations... look at you have to do this:


1. Delete your migration folder
2. Delete you app table manually (DROP table)
3. python manage.py makemigrations app_name
4. migrate

that's all

El sábado, 22 de septiembre de 2018, 4:10:45 (UTC-5), Srinivas Gadi escribió:
HI All,

I am facing below error while creating a new model class.
the error pop up only at this line "user = models.OneToOneField(User)"
"E1120:No value for argument 'on_delete' in constructor call"

from django.db import models
from django.contrib.auth.models import User

class userProfile(models.Model):
user = models.OneToOneField(User)

If I add "user = models.OneToOneField(User,on_delete=models.CASCADE)" the error got subsided but the new class "userProfile" is not appearing in admin page, under Users tab.

Could some one please guide me how to fix this ?

--
Srinivas .G
      9966559383

--
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/42ee3cf4-5347-4371-b9aa-343aa946c191%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment