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() On Tue, 10 Sep 2019 at 09:34, Sipum <sipu...@gmail.com> wrote: > 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, <replyvee...@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+unsubscr...@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 >> <https://groups.google.com/d/msgid/django-users/CANwgZcYfHyD1UGoG_faXv%3DBDnRVcHOBQoQ%3DovUhtV_14VVXmTw%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAGHZBzzkphdgsfhkk95vdTd0ZpW0%3Dx0STd4S9x7_LgxgYFk%2BWg%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAGHZBzzkphdgsfhkk95vdTd0ZpW0%3Dx0STd4S9x7_LgxgYFk%2BWg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANwgZcaQiUN9GY%3DyJMQfwHYE%3DL1H-Z9s%2BAygFLaxOQ8qABpiag%40mail.gmail.com.