On Sun, May 3, 2020 at 7:34 AM Vikram Jaiswal <vikramkumarjaiswal221998@gmail.com> wrote:
--above is the image of the erroradmin.pyfrom django.contrib import adminfrom travello.models import Destinationclass ContactAdmin(admin.ModelAdmin):Clist_display = [ 'name', 'department', 'lalal']# Register your models here.admin.site.register(Destination,ContactAdmin)models.pyfrom django.db import models# Create your models here.class Destination(models.Model):#id : intname : models.CharField(max_length=100)#strimg : models.ImageField(upload_to='pics')#strdesc : models.CharField(max_length=100)#strprice : models.IntegerField()#intoffer : models.BooleanField(default=False)#boolWhen i try to usepython manage.py makemigrationsthen in 0001_inital.py only contains id attribute.
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f60acf9d-d64d-4792-a9c1-5585d40758e6%40googlegroups.com.
To create the fields in Python models, we have to set the name of the attributes equal to the class of the field type. In simpler terms, using your model class and just the name attribute:
from django.db import models
class Destination(models.Model):
name = models.CharField(max_length=100)
Try setting the rest of the attributes using the assignment operator ('='), then run migrations again. You should see the fields in the admin.
-Jorge
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 view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CANfN%3DK85E13zVaOHuJA%2BMegWXq%2BSx%2BY8%2B7ymoUW4-9F-msikmw%40mail.gmail.com.
No comments:
Post a Comment