I understand. I'm not sure I see the reasons you can't achieve that with Satchmo's current Categories, but I'm guessing you're trying to ensure the restrictions are explicit. You could still do what you're wanting to do ... just don't use 'parent' as a field name, and everything will be fine.
Furthermore, since you are subclassing Category, you can control the admin form of AuthorCategory -- which means you can exclude 'parent' from showing up in AuthorCategory's ModelAdmin, while allowing it to show in BookCategory. Thus, you aren't really having to muck around too much with a field that already exists. On Tue, Mar 24, 2009 at 1:15 PM, Jon <[email protected]> wrote: > > Yeah. I was doing it intentionally - I knew what I was doing, I just > didn't know it wasn't allowed. > > What I want to do is replace the concept of a Category with a > ParentCategory that has no parents, but has children, and a > ChildCategory that has no children, but has a parent. The parent and > child models will have a few additional fields not included in the > Satchmo Category, but not the SAME few fields. > > I was hoping to use Django Admin to manage all of this, but I suppose > I can make my own views and handle the restrictions there. > > On Mar 24, 1:10 pm, Bob Waycott <[email protected]> wrote: > > Dang. I didn't even catch that. It's because you were using 'parent', > right? > > > > On Tue, Mar 24, 2009 at 9:27 AM, Jon <[email protected]> wrote: > > > > >http://docs.djangoproject.com/en/dev/topics/db/models/#field-name-hid. > .. > > > > > I'm violating one of Django's model rules and hiding a field from the > > > parent class. I'm actually kind of surprised it got as far as it did > > > before failing. > > > > > Anyway, I'm going to figure out a different way to do what I want. > > > Thanks for all your help. > > > > > On Mar 23, 11:47 pm, Bob Waycott <[email protected]> wrote: > > > > That's not seeming like such a huge problem to me. Out of curiosity, > does > > > > the error continue to occur if you remove the single quotes around > > > > AuthorCategory? I noticed earlier that you have that code defined > before > > > > BookCategory ... generally you only need quotes if you have not yet > > > defined > > > > the relationship model. > > > > I feel certain the relationship itself is not the problem. I say this > > > > because I am doing something similar with some extensive subclassing > of > > > > Satchmo's Product class like so: > > > > > > class CustomProdOne(Product): > > > > special_field = models.CharField() > > > > > > class CustomProdTwo(Product): > > > > prod_one = models.ForeignKey(CustomProdOne) > > > > ... more fields ... > > > > > > class CustomProdThree(Product): > > > > prod_one = models.ForeignKey(CustomProdOne) > > > > prod_two = models.ForeignKey(CustomProdTwo) > > > > ... more fields ... > > > > > > So, essentially I am doing the same thing, and more. > > > > > > Any chance you still receive the error if you completely drop all > tables > > > and > > > > re-syncdb from scratch? I can't really see your schema from here, but > > > Django > > > > is being pretty clear that the column it is trying to access simply > does > > > not > > > > exist in the db. > > > > > > On Mon, Mar 23, 2009 at 10:48 PM, Jon <[email protected]> wrote: > > > > > > > I think this is my issue: > > > > > class BookCategory(Category): > > > > > .... > > > > > parent = models.ForeignKey('AuthorCategory') > > > > > ... > > > > > > > The field "parent" already exists in Category, and I'm trying to > > > > > replace it with a subclass of Category. That is, a Category can > have > > > > > a Category as a parent, but I want a BookCategory to limit the > choice > > > > > of parents to AuthorCategories. I think there is probably a better > > > > > way to do this. > > > > > > > On Mar 23, 9:23 pm, Jon <[email protected]> wrote: > > > > > > Here's the error. What I mean by a built-in query is that this > is > > > all > > > > > > inside the Django admin. When I add a new BookCategory through > the > > > > > > admin and hit save, I get this error. Thanks again for all your > help > > > > > > in trying to pin down what's going on. > > > > > > Environment: > > > > > > > > Request Method: POST > > > > > > Request URL: > > >http://localhost:8081/admin/custom_satchmo/bookcategory/add/ > > > > > > Django Version: 1.0-final-SVN-unknown > > > > > > Python Version: 2.5.2 > > > > > > Installed Applications: > > > > > > ['django.contrib.admin', > > > > > > 'django.contrib.admindocs', > > > > > > 'django.contrib.auth', > > > > > > 'django.contrib.contenttypes', > > > > > > 'django.contrib.comments', > > > > > > 'django.contrib.sessions', > > > > > > 'django.contrib.sitemaps', > > > > > > 'django.contrib.sites', > > > > > > 'satchmo', > > > > > > 'satchmo.caching', > > > > > > 'satchmo.configuration', > > > > > > 'satchmo.shop', > > > > > > 'satchmo.contact', > > > > > > 'satchmo.product', > > > > > > 'satchmo.shipping', > > > > > > 'satchmo.payment', > > > > > > 'satchmo.discount', > > > > > > 'satchmo.giftcertificate', > > > > > > 'satchmo.supplier', > > > > > > 'satchmo.thumbnail', > > > > > > 'satchmo.l10n', > > > > > > 'satchmo.tax', > > > > > > 'satchmo.recentlist', > > > > > > 'satchmo.wishlist', > > > > > > 'satchmo.upsell', > > > > > > 'satchmo.productratings', > > > > > > 'store.site', > > > > > > 'store.custom_satchmo'] > > > > > > Installed Middleware: > > > > > > ('django.middleware.common.CommonMiddleware', > > > > > > 'django.contrib.sessions.middleware.SessionMiddleware', > > > > > > 'django.middleware.locale.LocaleMiddleware', > > > > > > 'django.contrib.auth.middleware.AuthenticationMiddleware', > > > > > > 'django.middleware.doc.XViewMiddleware', > > > > > > 'satchmo.shop.SSLMiddleware.SSLRedirect', > > > > > > 'satchmo.recentlist.middleware.RecentProductMiddleware') > > > > > > > > Traceback: > > > > > > File > "/var/lib/python-support/python2.5/django/core/handlers/base.py" > > > > > > in get_response > > > > > > 86. response = callback(request, > *callback_args, > > > > > > **callback_kwargs) > > > > > > File > > > "/var/lib/python-support/python2.5/django/contrib/admin/sites.py" > > > > > > in root > > > > > > 158. return self.model_page(request, > > > *url.split('/', > > > > > > 2)) > > > > > > File "/var/lib/python-support/python2.5/django/views/decorators/ > > > > > > cache.py" in _wrapped_view_func > > > > > > 44. response = view_func(request, *args, **kwargs) > > > > > > File > > > "/var/lib/python-support/python2.5/django/contrib/admin/sites.py" > > > > > > in model_page > > > > > > 177. return admin_obj(request, rest_of_url) > > > > > > File "/var/lib/python-support/python2.5/django/contrib/admin/ > > > > > > options.py" in __call__ > > > > > > 191. return self.add_view(request) > > > > > > File "/var/lib/python-support/python2.5/django/db/transaction.py" > in > > > > > > _commit_on_success > > > > > > 238. res = func(*args, **kw) > > > > > > File "/var/lib/python-support/python2.5/django/contrib/admin/ > > > > > > options.py" in add_view > > > > > > 502. self.save_model(request, new_object, form, > > > > > > change=False) > > > > > > File "/var/lib/python-support/python2.5/django/contrib/admin/ > > > > > > options.py" in save_model > > > > > > 376. obj.save() > > > > > > File "/usr/lib/python2.5/site-packages/satchmo/product/models.py" > in > > > > > > save > > > > > > 223. self.slug = slugify(self.name, instance=self) > > > > > > File > "/usr/lib/python2.5/site-packages/satchmo/utils/unique_id.py" in > > > > > > slugify > > > > > > 95. while get_query(): > > > > > > File > "/var/lib/python-support/python2.5/django/db/models/query.py" in > > > > > > __nonzero__ > > > > > > 185. iter(self).next() > > > > > > File > "/var/lib/python-support/python2.5/django/db/models/query.py" in > > > > > > _result_iter > > > > > > 179. self._fill_cache() > > > > > > File > "/var/lib/python-support/python2.5/django/db/models/query.py" in > > > > > > _fill_cache > > > > > > 612. > self._result_cache.append(self._iter.next > > > > > > ()) > > > > > > File > "/var/lib/python-support/python2.5/django/db/models/query.py" in > > > > > > iterator > > > > > > 269. for row in self.query.results_iter(): > > > > > > File > > > "/var/lib/python-support/python2.5/django/db/models/sql/query.py" > > > > > > in results_iter > > > > > > 206. for rows in self.execute_sql(MULTI): > > > > > > File > > > "/var/lib/python-support/python2.5/django/db/models/sql/query.py" > > > > > > in execute_sql > > > > > > 1700. cursor.execute(sql, params) > > > > > > File > "/var/lib/python-support/python2.5/django/db/backends/util.py" > > > in > > > > > > execute > > > > > > 19. return self.cursor.execute(sql, params) > > > > > > File > "/var/lib/python-support/python2.5/django/db/backends/sqlite3/ > > > > > > base.py" in execute > > > > > > 167. return Database.Cursor.execute(self, query, > params) > > > > > > > > Exception Type: OperationalError at > > > /admin/custom_satchmo/bookcategory/ > > > > > > add/ > > > > > > Exception Value: no such column: > > > > > > custom_satchmo_authorcategory.category_ptr_id > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Satchmo users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/satchmo-users?hl=en -~----------~----~----~----~------~----~------~--~---
