Josh,
*Thanks so much for stepping up to lend a hand!! Much appreciated! :D*
I'm getting a "models not loaded yet" exception:
File "/home/dad/openshift/blog/wsgi/admin.py", line 4, in <module>
from mezzanine.blog.admin import BlogCategoryAdmin
File "/usr/local/lib/python2.7/dist-packages/mezzanine/blog/admin.py",
line 10, in <module>
from mezzanine.core.admin import (DisplayableAdmin, OwnableAdmin,
File "/usr/local/lib/python2.7/dist-packages/mezzanine/core/admin.py",
line 52, in <module>
User = get_user_model()
File
"/usr/local/lib/python2.7/dist-packages/django/contrib/auth/__init__.py",
line 150, in get_user_model
return django_apps.get_model(settings.AUTH_USER_MODEL)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
line 199, in get_model
self.check_models_ready()
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py",
line 131, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
Not sure if I need to add an AUTH_USER_MODEL setting in settings.py (it
does not have one).
Thanks again for giving it a look!
J.
On Sunday, September 13, 2015 at 8:02:30 PM UTC-4, Josh B wrote:
>
> Hey J M. You shouldn't need the models.py file. I think you if you add the
> following to your admin.py you will be good to go.
>
> from copy import deepcopy
> from django.contrib import admin
> from mezzanine.blog.admin import BlogCategoryAdmin
> from mezzanine.blog.models import BlogCategory
>
> blog_fieldsets = deepcopy(BlogCategoryAdmin.fieldsets)
> blog_fieldsets[0][1]["fields"].extend(["catType"])
>
> class MyBlogCategoryAdmin(BlogCategoryAdmin):
> fieldsets = blog_fieldsets
>
> if BlogCategory in admin.site._registry:
> admin.site.unregister(BlogCategory)
> admin.site.register(BlogCategory, MyBlogCategoryAdmin)
>
> if BlogCategory in admin.site._registry:
> admin.site.unregister(BlogCategory)
>
>
> On Sunday, September 13, 2015 at 9:56:13 AM UTC-6, J M wrote:
>>
>> *Bump* Anyone??
>>
>> On Friday, September 11, 2015 at 3:16:25 AM UTC-4, J M wrote:
>>>
>>> I'm trying to to add a new field to blog category called "catType". The
>>> purpose of this new 1 character field is to use it in templates (eg. if
>>> catType = '-' don't display the category or '+' to highlight the
>>> category). I need to be able to update it from the category admin page.
>>>
>>> I've looked for help from a bunch of various guides/instructions eg:
>>> http://mezzanine.jupo.org/docs/model-customization.html
>>>
>>> https://stackoverflow.com/questions/15345067/add-a-field-to-mezzanine-blogpost
>>>
>>>
>>> https://stackoverflow.com/questions/19935812/mezzanine-field-missing-from-the-form
>>>
>>> So far I've only got this working:
>>>
>>> in settings.py:
>>> EXTRA_MODEL_FIELDS = (
>>> ( "mezzanine.blog.models.BlogCategory.catType",
>>> "django.db.models.CharField",
>>> ("Category Type",),
>>> {"max_length":1, "blank": False, "null": True, "default": True},
>>> ),
>>> )
>>>
>>>
>>> sudo python manage.py makemigrations
>>> python manage.py syncdb
>>>
>>> the new field "catType" is there...
>>>
>>> sqlite> .schema blog_blogcategory
>>> CREATE TABLE "blog_blogcategory" ("id" integer NOT NULL PRIMARY KEY
>>> AUTOINCREMENT, "title" varchar(500) NOT NULL, "slug" varchar(2000) NULL,
>>> "site_id" integer NOT NULL REFERENCES "django_site" ("id"), "catType"
>>> varchar(1) NULL);
>>> CREATE INDEX "blog_blogcategory_9365d6e7" ON "blog_blogcategory" (
>>> "site_id");
>>>
>>>
>>> =======================================
>>> this part isn't working...
>>> =======================================
>>>
>>> I've created this "admin.py" and put it in my project's directory...
>>>
>>> from copy import deepcopy
>>> from django.contrib import admin
>>> from mezzanine.blog.admin import BlogCategoryAdmin
>>> from mezzanine.blog.models import BlogCategory
>>>
>>> blog_fieldsets = deepcopy(BlogCategoryAdmin.fieldsets)
>>> blog_fieldsets[0][1]["fields"].extend(["catType"])
>>>
>>> class MyBlogCategoryAdmin(BlogCategoryAdmin):
>>> fieldsets = blog_fieldsets
>>>
>>> admin.site.unregister(BlogCategory)
>>> admin.site.register(BlogCategory, MyBlogCategoryAdmin)
>>>
>>>
>>> I've created this "models.py" and put it in my project's directory...
>>>
>>> from django.db import models
>>> from mezzanine.pages.models import Page
>>> print "in models"
>>> print "in models"
>>> print "in models"
>>> class MyPage(Page):
>>> catType = models.TextField(max_length=1, blank=True, null=True)
>>>
>>>
>>> My problem is that I don't really know what the correct steps are.
>>>
>>> If I add "admin" to apps I get "models aren't loaded yet".
>>>
>>> Any assistance would be much appreciated!
>>>
>>>
--
You received this message because you are subscribed to the Google Groups
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.