Monday, May 27, 2019

Re: What's wrong with this model

Yes, your are adding new field elogin.
Table contains data
You must specify a default on all existing rows, selecting 1 and writing to console something










Missatge de Saeed Pooladzadeh <lingo1357@gmail.com> del dia dl., 27 de maig 2019 a les 23:52:
Hello

I made this model and think everything is fine:

class Smodel(models.Model):

    eid=models.AutoField(primary_key=True)
   # eid=models.IntegerField(default=0)
    elogin = models.CharField(max_length=8) 
    epassword= models.CharField(max_length=8) 
  
    elikeDay=models.IntegerField(default=0)
    efollowPerDay=models.IntegerField(default=0)
    

   
    #esession = models.TextField()
    class Meta:  
        db_table = "saeed"  


  'But when I try to 'make migration 
I get this error:

You are trying to add a non-nullable field 'elogin' to smodel without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix:
 1) Provide a one-off default now (will be set on all existing rows with a null value for this column)
 2) Quit, and let me add a default in models.py
Select an option: 


What is wrong with this model and how can I resolve it?

regards,
Saeed 

--
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/dee2a6de-49e9-45c4-8536-0bed15038bd9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
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/CAK-JoTRHJaa2-QPE1CJCZnCbQBpGgGQasuNK3%2B5E6TQ6J9bQxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment