migrate error

22 views
Skip to first unread message

Pradeep Singh

unread,
Sep 9, 2019, 10:44:28 PM9/9/19
to django...@googlegroups.com
 I didnot get why i am getting this error .please help to fix it 
Screenshot (230).png

Sipum

unread,
Sep 10, 2019, 12:04:29 AM9/10/19
to django...@googlegroups.com
Show the code where u have used datetime.datetime.

Whenever u are asking something, its better to show code where the error is arised. So it will be easy for others to find the error otherwise no one will answer ur question bro. 

On Tue, 10 Sep, 2019, 8:14 AM Pradeep Singh, <reply...@gmail.com> wrote:
 I didnot get why i am getting this error .please help to fix it 

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANwgZcYfHyD1UGoG_faXv%3DBDnRVcHOBQoQ%3DovUhtV_14VVXmTw%40mail.gmail.com.

Pradeep Singh

unread,
Sep 10, 2019, 12:29:53 AM9/10/19
to django...@googlegroups.com
from django.db import models
from django import forms
from django.core import validators
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver
from django.utils import timezone
from datetime import datetime
# Create your models here.
class Contact(models.Model):
  name = models.CharField(max_length=200)
  email = models.CharField(max_length=100)
  phone = models.CharField(max_length=100)
  message = models.TextField(blank=True)
  contact_date = models.DateTimeField(default=datetime.now, blank=True)

  def __str__(self):
    return self.name

class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    bio = models.TextField(max_length=500, blank=True)
    location = models.CharField(max_length=30, blank=True)
    #sbirth_date = models.DateField(null=True, blank=True)

@receiver(post_save, sender=User)
def update_user_profile(sender, instance, created, **kwargs):
    if created:
        Profile.objects.create(user=instance)
        instance.profile.save()

class Realtor(models.Model):
  name = models.CharField(max_length=200)
  photo = models.ImageField(upload_to='media/images/')
  description = models.TextField(blank=True)
  phone = models.CharField(max_length=20)
  email = models.CharField(max_length=50)
  is_mvp = models.BooleanField(default=False)
  hire_date = models.DateTimeField(default=datetime.now, blank=True)
  def __str__(self):
    return self.name

PROPERTY_TYPE = (('Select Property Type','Select Property Type'),('Appartment', 'Appartment'),('DDA Appartment', 'DDA Appartment'), ('Builder Floor', 'Builder Floor'), ('Indepedent house', 'Indepedent house'),('Residental Land','Residental Land'))
TYPE = (('Select Type','Select Type'),('1 BHK', '1 BHK'), ('2 BHK', '2 BHK'), ('3 BHK', '3 BHK'),('4 BHK','4 BHK'),('LAND','Land'),('Janta Flat','Janta Flat'),('LIG Flat','LIG Flat'),('MIG Flat','MIG Flat'),('HIG Flat','HIG Flat'))
CITY=(('Select City','Select City'),('West Delhi', 'West Delhi'), ('South Delhi', 'South Delhi'), ('North Delhi', 'North Delhi'),('East Delhi','East Delhi'))

class Property(models.Model):
    realtor= models.ForeignKey(Realtor,  on_delete=models.DO_NOTHING)
    #image=models.ImageField(upload_to='media/images/',blank=True, null=True)
    house_name=models.CharField(max_length=30)
    #PROPERTY_TYPE = (('Select Property Type','Select Property Type'),('Appartment', 'Appartment'),('DDA Appartment', 'DDA Appartment'), ('Builder Floor', 'Builder Floor'), ('Indepedent house', 'Indepedent house'),('Residental Land','Residental Land'))
    property_type=models.CharField(max_length=20, choices=PROPERTY_TYPE,default='Select Property Type')
    #TYPE = (('Select Type','Select Type'),('1 BHK', '1 BHK'), ('2 BHK', '2 BHK'), ('3 BHK', '3 BHK'),('4 BHK','4 BHK'),('LAND','Land'),('Janta Flat','Janta Flat'),('LIG Flat','LIG Flat'),('MIG Flat','MIG Flat'),('HIG Flat','HIG Flat'))
    type=models.CharField(max_length=10,choices=TYPE,default='Select Type')
    area=models.CharField(max_length=10,blank=False)
    #CITY=(('Select City','Select City'),('West Delhi', 'West Delhi'), ('South Delhi', 'South Delhi'), ('North Delhi', 'North Delhi'),('East Delhi','East Delhi'))
    city=models.CharField(max_length=20,choices=CITY,default='Select city')
    location=models.CharField(max_length=30)
    price=models.CharField(max_length=20)
    description=models.TextField(blank=True)
    publish_date = models.DateTimeField(default=datetime.now, blank=True)
    publish_date = models.DateTimeField(default=datetime.now, blank=True)
    image= models.ImageField(upload_to='media/images/',blank=True, null=True )
    image_1 = models.ImageField(upload_to='media/images/', blank=True , null=True)
    image_2 = models.ImageField(upload_to='media/images/', blank=True , null=True)
    image_3 = models.ImageField(upload_to='media/images/', blank=True , null=True)
    image_4 = models.ImageField(upload_to='media/images/', blank=True , null=True)
    image_5 = models.ImageField(upload_to='media/images/', blank=True , null=True)
    image_6 = models.ImageField(upload_to='media/images/', blank=True , null=True)
    #submitted = models.DateField(auto_now_add=True)

    class Meta:
        abstract=True




class Buy(Property):

    def __str__(self):
        return self.house_name


class Rent(Property):

    def __str__(self):
        return self.house_name

class PG(Property):
    def __str__(self):
        return self.house_name


YOU_ARE=(('Select','Select'),('Owner', 'Owner'), ('Dealer', 'Dealer'), ('Agent', 'Agent'))
PROPERTY_FOR=(('Select Property For','Select Property For'), ('Sale', 'Sale'), ('Rent', 'Rent'), ('PG', 'PG'))
PROPERTY_TYPE = (('Select Property Type','Select Property Type'),('Appartment', 'Appartment'),('DDA Appartment', 'DDA Appartment'), ('Builder Floor', 'Builder Floor'), ('Indepedent house', 'Indepedent house'),('Residental Land','Residental Land'))
TYPE = (('Select Type','Select Type'),('1 BHK', '1 BHK'), ('2 BHK', '2 BHK'), ('3 BHK', '3 BHK'),('4 BHK','4 BHK'),('LAND','Land'),('Janta Flat','Janta Flat'),('LIG Flat','LIG Flat'),('MIG Flat','MIG Flat'),('HIG Flat','HIG Flat'))
CITY=(('Select City','Select City'),('West Delhi', 'West Delhi'), ('South Delhi', 'South Delhi'), ('North Delhi', 'North Delhi'),('East Delhi','East Delhi'))


class PostProperty(models.Model):
    username = models.ForeignKey(User, blank=True, null=True)
    name=models.CharField(max_length=30)
    email=models.EmailField()
    contact=models.IntegerField()
    you_are=models.CharField(max_length=20,choices=YOU_ARE,default='Select')
    property_for=models.CharField(max_length=20,choices=PROPERTY_FOR,default='Select Property For')
    property_type=models.CharField(max_length=20, choices=PROPERTY_TYPE,default='Select Property Type')
    type=models.CharField(max_length=10,choices=TYPE,default='Select Type')

    appartment_name_or_House_name=models.CharField(max_length=50)
    property_description=models.TextField()
    area=models.CharField(max_length=10)
    city=models.CharField(max_length=20,choices=CITY,default='Select city')
    locality=models.CharField(max_length=30)
    address_1=models.CharField(max_length=254)
    address_2=models.CharField(max_length=254)
    pincode=models.IntegerField()
    expected_amount=models.CharField(max_length=20)
    publish_date = models.DateTimeField(default=datetime.now, blank=True)
    image= models.ImageField(upload_to='media/images/',blank=True, null=True )
    image_1 = models.ImageField(upload_to='media/images/', blank=True , null=True)
    image_2 = models.ImageField(upload_to='media/images/', blank=True , null=True)
    image_3 = models.ImageField(upload_to='media/images/', blank=True , null=True)
    image_4 = models.ImageField(upload_to='media/images/', blank=True , null=True)
    image_5 = models.ImageField(upload_to='media/images/', blank=True , null=True)
    image_6 = models.ImageField(upload_to='media/images/', blank=True , null=True)
    def __str__(self):
        return self.appartment_name_or_House_name

    def get_absolute_url(self):
        return reverse('thanks')

#class Profile(models.Model):
#    user = models.OneToOneField(User, on_delete=models.CASCADE)
    #bio = models.TextField(max_length=500, blank=True)
    #location = models.CharField(max_length=30, blank=True)
    #birth_date = models.DateField(null=True, blank=True)


#@receiver(post_save, sender=User)
#def update_user_profile(sender, instance, created, **kwargs):
    #if created:
        #Profile.objects.create(user=instance)
    #instance.profile.save()

ANi

unread,
Sep 10, 2019, 2:51:35 AM9/10/19
to Django users

 
Another piece of advice, please prettify your code or take a screenshot, not just paste it directly.
 
It is not easy to read to you as well, right?



what had you done in this migration?
Was the original value in that column a datetime and you want to change it into another data format?


Pradeep Singh於 2019年9月10日星期二 UTC+8上午10時44分28秒寫道:

Rahul Roshan

unread,
Sep 10, 2019, 3:19:41 AM9/10/19
to django...@googlegroups.com
Can you try contact_date default=" " !

--
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.

Pradeep Singh

unread,
Sep 10, 2019, 4:12:47 AM9/10/19
to django...@googlegroups.com
okay . yes i did but problem are same 

Rahul Roshan

unread,
Sep 10, 2019, 4:39:37 AM9/10/19
to django...@googlegroups.com
First you can cleanup all migrations files in /migrations/*. And then try to provide default=" " for contact_no. Try to migrate all these changes !

Chukwuka

unread,
Sep 10, 2019, 10:34:15 AM9/10/19
to django...@googlegroups.com
Might help if you post the migration file 0027.. for testapp

Desh Deepak

unread,
Sep 10, 2019, 12:39:43 PM9/10/19
to django...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages