Saturday, December 16, 2017

Re: having trouble with django models

On 16/12/2017 10:06 PM, Mukul Agrawal wrote:
> Hello, I am newbie to django. I was trying my hand on models. When i
> used the below code in models.py, "timestamp" and "updated" are not
> able visible on admin site. Is something wrong with the code?

It looks OK to me. Have you included them in your admin.py ...
        fieldsets = (
            ('RestaurantLocation', {
                'fields': (
                    'name',
                    'location',
                    'category',
                    'timestamp',
                    'updated',
                    ),
                }
            ),
        )


>
> '''
> from django.db import models
>
> # Create your models here.
> class RestaurantLocation(models.Model):
>     name             = models.CharField(max_length=120)
>     location         = models.CharField(max_length=120, null=True,
> blank=True)
>     category         = models.CharField(max_length=120, null=True,
> blank=True)
>     timestamp        =
> models.DateTimeField(auto_now=False,auto_now_add=True)
>     updated          = models.DateTimeField(auto_now=True,
> auto_now_add=False)
> '''
> --
> 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
> <mailto:django-users+unsubscribe@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto: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/a80a81c1-fade-42a0-b8f5-20638541a5bf%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a80a81c1-fade-42a0-b8f5-20638541a5bf%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 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/83a8f5c8-3db4-b684-f612-b48e40a06752%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment