django cms beginner app issue

50 views
Skip to first unread message

Keegen Knapp

unread,
Mar 25, 2019, 7:06:40 PM3/25/19
to Django users
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 - 

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()),
)



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)

LIGHTNING OMEGA 2 636

unread,
Mar 25, 2019, 7:58:01 PM3/25/19
to django...@googlegroups.com
Just letting you know that, I've read msg and reviewed you code.  Although these are interview objects, it uses word tokens.   Key words such as those used in this code are handled well by utilizing Natural Language Processing (NLP) methods.   Mapping and Regular Expressions (Regex) do alot of the work in Python, R, React JavaScript etc.  Now I need to see if Turbo Pascal supports these libraries of code.   If it's okay, maybe Tomorrow or Thurs will work as far as meeting is concerned.

--
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.

Keegen Knapp

unread,
Mar 26, 2019, 8:01:02 AM3/26/19
to Django users
sorry, that doesn't make sense. maybe that was meant for a different post?

Avraham Serour

unread,
Mar 26, 2019, 8:09:59 AM3/26/19
to django-users
you model doesn't have app_config

--

Keegen Knapp

unread,
Mar 26, 2019, 9:16:40 AM3/26/19
to Django users
so I'm missing a line of code in my models.py?
Reply all
Reply to author
Forward
0 new messages