you model doesn't have app_config

On Tue, Mar 26, 2019 at 1:07 AM Keegen Knapp <[email protected]> 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 -
>
> [image: Screen Shot 2019-03-25 at 11.25.09 AM.png]
>
>
> models.py -
>
> from django.db import models
> from cms.models.fields import PlaceholderField
> from django.db.models.signals import pre_save
>
> #create a basic species model
> class Species(models.Model):
> name = models.CharField(max_length=50, unique=True)
> def __unicode__(self):
> return self.name
>
> class Plant(models.Model):
> name = models.CharField(max_length=50, unique=True)
> #textfield to choose season
> season = models.TextField()
> #automatically adds a created date, good for ordering plants by dates etc
> pub_date = models.DateField(auto_now_add=True)
> #automatically adds slug, requires Auto slug
> slug = models.SlugField(max_length=70, unique=True)
> #FK's to a species model
> species = models.ForeignKey(Species)
> #life cycle
> life_cycle = models.CharField(max_length=60)
> #add a upload section for specification sheets
> position = models.TextField()
> #take advantage of the CMS's placeholders for images, much more flexible
> than file_upload
> image = PlaceholderField('plant_images', related_name="image")
> #again description, take advantage of the CMS capabilities.
> description = PlaceholderField('plant_description',
> related_name="description")
>
>
> *views.py*
>
> from django.shortcuts import render_to_response
> from django.template import RequestContext
>
> class ProductDetailView(DetailView):
> model = Plant
> template_name = 'plants/detail.html'
>
>
> *urls.py*
> from plants.views import PlantDetailView
>
> urlpatterns = patterns('plants.views',
> url(r'^(?P<slug>[\w-]+)/$', PlantDetailView.as_view()),
> )
>
>
> *cms.app.py <http://cms.app.py/> -*
>
> from cms.app_base import CMSApp
> from cms.apphook_pool import apphook_pool
> from django.utils.translation import ugettext_lazy as _
>
> class PlantsApp(CMSApp):
> name = _("Plants") # give your app a name, this is required
> urls = ["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 admin
> from .models import Plant, Species
> from aldryn_apphooks_config.admin import ModelAppHookConfig,
> BaseAppHookConfig
>
> class PlantAdmin(ModelAppHookConfig, admin.ModelAdmin):
> search_fields = ['name']
> readonly_fields = ['slug']
> ordering = ['name']
> pass
> admin.site.register(Plant, PlantAdmin)
>
>
> class SpeciesAdmin(admin.ModelAdmin):
> search_fields = ['name']
> ordering = ['name']
> pass
> admin.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 [email protected].
> To post to this group, send email to [email protected].
> 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
> <https://groups.google.com/d/msgid/django-users/f5c0d1e5-3962-48ce-8fdc-a082c37ddba5%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 [email protected].
To post to this group, send email to [email protected].
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/CAFWa6tK8hny1LH%3D5JzkrpiD4DRTRF9yk%3DhbeV9eW-w6GTWwSMg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to