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

class Customer(models.Model):
    user=models.OneToOneField(User,null=True,on_delete= models.CASCADE)
    name=models.CharField(max_length=200,null=True)
    phone=models.CharField(max_length=200,null=True)
    email=models.CharField(max_length=200,null=True)
    profile_pic = models.ImageField(default="radha3.png", null=True, blank=True)
    date_created=models.DateTimeField(auto_now_add=True,null=True)
    def __str__(self):
        return str(self.name)

class Tag(models.Model):
    name=models.CharField(max_length=200,null=True)
    def __str__(self):
        return str(self.name)


class Product(models.Model):
    CATEGORY=(
        ('In door','In door'),
        ('Out door','Out door'),
    )
    name=models.CharField(max_length=100,null=True)
    price=models.FloatField(null=True)
    category = models.CharField(max_length=200, null=True,choices=CATEGORY)
    description = models.CharField(max_length=200,null=True,blank=True)
    date_created = models.DateTimeField(auto_now_add=True, null=True)
    tags=models.ManyToManyField(Tag)

    def __str__(self):
        return str(self.name)



class Order(models.Model):
    STATUS = (
        ('Pending', 'Pending'),
        ('Out for delivery', 'Out for delivery'),
        ('Delivered', 'Delivered'),
    )
    customer = models.ForeignKey(Customer, null=True, on_delete=models.SET_NULL)
    product = models.ForeignKey(Product, null=True, on_delete=models.SET_NULL)
    date_created = models.DateTimeField(auto_now_add=True, null=True)
    status = models.CharField(max_length=200, null=True, choices=STATUS)
    note = models.CharField(max_length=1000, null=True)

    def __str__(self):
        return str(self.product.name)


Try this and let me know whether it is working or not. I added str()
to the __str__. All the best


On Fri, Jul 31, 2020 at 7:17 PM ROHINI PUNDE <punderoh...@gmail.com> wrote:

> from django.db import models
> from django.contrib.auth.models import User
>
> class Customer(models.Model):
>     user=models.OneToOneField(User,null=True,on_delete= models.CASCADE)
>     name=models.CharField(max_length=200,null=True)
>     phone=models.CharField(max_length=200,null=True)
>     email=models.CharField(max_length=200,null=True)
>     profile_pic = models.ImageField(default="radha3.png", null=True, 
> blank=True)
>     date_created=models.DateTimeField(auto_now_add=True,null=True)
>     def __str__(self):
>         return self.name
>
> class Tag(models.Model):
>     name=models.CharField(max_length=200,null=True)
>     def __str__(self):
>         return self.name
>
> class Product(models.Model):
>     CATEGORY=(
>         ('In door','In door'),
>         ('Out door','Out door'),
>     )
>     name=models.CharField(max_length=100,null=True)
>     price=models.FloatField(null=True)
>     category = models.CharField(max_length=200, null=True,choices=CATEGORY)
>     description = models.CharField(max_length=200,null=True,blank=True)
>     date_created = models.DateTimeField(auto_now_add=True, null=True)
>     tags=models.ManyToManyField(Tag)
>
>     def __str__(self):
>         return self.name
>
>
> class Order(models.Model):
>     STATUS = (
>         ('Pending', 'Pending'),
>         ('Out for delivery', 'Out for delivery'),
>         ('Delivered', 'Delivered'),
>     )
>     customer = models.ForeignKey(Customer, null=True, 
> on_delete=models.SET_NULL)
>     product = models.ForeignKey(Product, null=True, on_delete=models.SET_NULL)
>     date_created = models.DateTimeField(auto_now_add=True, null=True)
>     status = models.CharField(max_length=200, null=True, choices=STATUS)
>     note = models.CharField(max_length=1000, null=True)
>
>     def __str__(self):
>         return self.product.name
>
>
>
> On Thu, Jul 30, 2020 at 7:41 PM RANGA BHARATH JINKA <
> bharathjink...@gmail.com> wrote:
>
>> Send your models.py file
>>
>> On Fri, 31 Jul 2020, 8:09 am RANGA BHARATH JINKA, <
>> bharathjink...@gmail.com> wrote:
>>
>>> Hi convert it into string while displaying it in models __str__.
>>> Or use f-strings. It is easy. All the best 👍
>>>
>>> On Thu, 30 Jul 2020, 8:29 pm ROHINI PUNDE, <punderoh...@gmail.com>
>>> wrote:
>>>
>>>> I have error while updating the information,so many trials I cant solve
>>>> this problem,so please help me for this
>>>>
>>>>
>>>> On Thu, Jul 30, 2020 at 2:25 AM Mira <mirathe...@gmail.com> wrote:
>>>>
>>>>> Hi All,
>>>>> I recently upgraded Django from 2.2 to 3 on my MacOS10.13.
>>>>> I am using Python 3.6 and My Application was working fine with Django
>>>>> 2.2 but now i am getting below error.
>>>>>
>>>>> Any help related with this topic would be greatly appreciated.
>>>>>
>>>>> $>python3 manage.py runserver
>>>>>
>>>>> Watching for file changes with StatReloader
>>>>>
>>>>> Performing system checks...
>>>>>
>>>>>
>>>>> Traceback (most recent call last):
>>>>>
>>>>>   File "manage.py", line 22, in <module>
>>>>>
>>>>>     execute_from_command_line(sys.argv)
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py",
>>>>> line 401, in execute_from_command_line
>>>>>
>>>>>     utility.execute()
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/__init__.py",
>>>>> line 395, in execute
>>>>>
>>>>>     self.fetch_command(subcommand).run_from_argv(self.argv)
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py",
>>>>> line 328, in run_from_argv
>>>>>
>>>>>     self.execute(*args, **cmd_options)
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>>>>> line 60, in execute
>>>>>
>>>>>     super().execute(*args, **options)
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py",
>>>>> line 369, in execute
>>>>>
>>>>>     output = self.handle(*args, **options)
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>>>>> line 95, in handle
>>>>>
>>>>>     self.run(**options)
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>>>>> line 102, in run
>>>>>
>>>>>     autoreload.run_with_reloader(self.inner_run, **options)
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
>>>>> line 599, in run_with_reloader
>>>>>
>>>>>     start_django(reloader, main_func, *args, **kwargs)
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
>>>>> line 584, in start_django
>>>>>
>>>>>     reloader.run(django_main_thread)
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
>>>>> line 299, in run
>>>>>
>>>>>     self.run_loop()
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
>>>>> line 305, in run_loop
>>>>>
>>>>>     next(ticker)
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
>>>>> line 345, in tick
>>>>>
>>>>>     for filepath, mtime in self.snapshot_files():
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
>>>>> line 361, in snapshot_files
>>>>>
>>>>>     for file in self.watched_files():
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
>>>>> line 260, in watched_files
>>>>>
>>>>>     yield from iter_all_python_module_files()
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
>>>>> line 105, in iter_all_python_module_files
>>>>>
>>>>>     return iter_modules_and_files(modules, frozenset(_error_files))
>>>>>
>>>>>   File
>>>>> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py",
>>>>> line 141, in iter_modules_and_files
>>>>>
>>>>>     resolved_path = path.resolve(strict=True).absolute()
>>>>>
>>>>> TypeError: resolve() got an unexpected keyword argument 'strict'
>>>>>
>>>>> udaysingh@udays-MacBook-Pro:~/Django/dreamProj>
>>>>>
>>>>> --
>>>>> 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/CAANDXNtvg9sP5OqLktcECco1MhpV0%3DcMgYCKvAF0TLXAH9bpog%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/django-users/CAANDXNtvg9sP5OqLktcECco1MhpV0%3DcMgYCKvAF0TLXAH9bpog%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/CAO9_9ZYc52ZYZQfQn_dg%3DtmHKra%3D16KcdGXrLTM3%3DX5Bg9N%2BrQ%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CAO9_9ZYc52ZYZQfQn_dg%3DtmHKra%3D16KcdGXrLTM3%3DX5Bg9N%2BrQ%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/CAK5m314E5Z99zx5wZkNKcKnZrvqSQk9tMLmk7TwxrU89-bnwaw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAK5m314E5Z99zx5wZkNKcKnZrvqSQk9tMLmk7TwxrU89-bnwaw%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/CAO9_9ZYTQLQTnJrXPxvcELyzTkeTnucNp1PMSszTvb81%3DMCFjw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAO9_9ZYTQLQTnJrXPxvcELyzTkeTnucNp1PMSszTvb81%3DMCFjw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Thanks and Regards

J. Ranga Bharath
cell: 9110334114

-- 
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/CAK5m316eSjH4UHsBKYw13t1f3t_f2ke7D2C_W7-kp5UnABeVXg%40mail.gmail.com.

Reply via email to