so I'm missing a line of code in my models.py?
On Tuesday, March 26, 2019 at 7:09:59 AM UTC-5, Avraham Serour wrote:
-- On Tuesday, March 26, 2019 at 7:09:59 AM UTC-5, Avraham Serour wrote:
you model doesn't have app_configOn Tue, Mar 26, 2019 at 1:07 AM Keegen Knapp <kee...@gmail.com> wrote:I'm trying to write a custom app where you can add new plants in the admin. Then create a list view, category view and detailed view. You can see my error and code below. Any help is greatly appreciated!!--Error -
models.py -from django.db import modelsfrom cms.models.fields import PlaceholderFieldfrom django.db.models.signals import pre_save#create a basic species modelclass Species(models.Model):name = models.CharField(max_length=50, unique=True) def __unicode__(self):return self.nameclass Plant(models.Model):name = models.CharField(max_length=50, unique=True) #textfield to choose seasonseason = models.TextField()#automatically adds a created date, good for ordering plants by dates etcpub_date = models.DateField(auto_now_add=True) #automatically adds slug, requires Auto slugslug = models.SlugField(max_length=70, unique=True) #FK's to a species modelspecies = models.ForeignKey(Species)#life cyclelife_cycle = models.CharField(max_length=60) #add a upload section for specification sheetsposition = models.TextField()#take advantage of the CMS's placeholders for images, much more flexible than file_uploadimage = PlaceholderField('plant_images', related_name="image") #again description, take advantage of the CMS capabilities.description = PlaceholderField('plant_description', related_name="description") views.pyfrom django.shortcuts import render_to_responsefrom django.template import RequestContextclass ProductDetailView(DetailView):model = Planttemplate_name = 'plants/detail.html'urls.pyfrom plants.views import PlantDetailViewurlpatterns = patterns('plants.views',url(r'^(?P<slug>[\w-]+)/$', PlantDetailView.as_view()),)from cms.app_base import CMSAppfrom cms.apphook_pool import apphook_poolfrom django.utils.translation import ugettext_lazy as _class PlantsApp(CMSApp):name = _("Plants") # give your app a name, this is requiredurls = ["plants.urls"] # link your app to url configuration(s)def get_urls(self, page=None, language=None, **kwargs):return ["plants.urls"]apphook_pool.register(PlantsApp) # register your app apps.py -class PlantsConfig(AppConfig):name = 'plants'verbosename = "Plants"admin.py -from django.contrib import adminfrom .models import Plant, Speciesfrom aldryn_apphooks_config.admin import ModelAppHookConfig, BaseAppHookConfigclass PlantAdmin(ModelAppHookConfig, admin.ModelAdmin):search_fields = ['name']readonly_fields = ['slug']ordering = ['name']passadmin.site.register(Plant, PlantAdmin)class SpeciesAdmin(admin.ModelAdmin): search_fields = ['name']ordering = ['name']passadmin.site.register(Species, SpeciesAdmin)
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 post to this group, send email to django...@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/f5c0d1e5- .3962-48ce-8fdc-a082c37ddba5% 40googlegroups.com
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/be2fab33-303c-47c1-a06b-e90d531edc85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:
Post a Comment