Git Product home page Git Product logo

Comments (12)

tereza avatar tereza commented on August 20, 2024

Forgot to mention: Using Django 1.4.1, South 0.7.6, Django-categories 1.1.4

from django-categories.

jsoa avatar jsoa commented on August 20, 2024

Can you try just running ./manage.py syncdb --migrate.

from django-categories.

tereza avatar tereza commented on August 20, 2024

It created a M2M table for "categories", but don’t tables have to be created for my M2M "Audience" and "Diagnosis" models? Isn’t that what "add_category_fields" is for?

Or have I misunderstood its purpose?

t

On Sep 27, 2012, at 1:04 PM, Jose Soares wrote:

Can you try just running ./manage.py syncdb --migrate.


Reply to this email directly or view it on GitHub.

from django-categories.

coordt avatar coordt commented on August 20, 2024

Actually, Many-To-Many relations are not connected by a foreign key. A intermediate table is created that has a foreign key to categories and to the other model.

You should have an intermediary table between Category and ResourceEntry.

You have, it seems, discovered a bug in the add_category_fields command, but it shouldn't be relevant for your setup.

If you run your application and go to the ResourceEntry model, do you get an error, or do you see your category fields?

Corey

On Sep 27, 2012, at 1:55 PM, Tereza Snyder [email protected] wrote:

It created a M2M table for "categories", but don’t tables have to be created for my M2M "Audience" and "Diagnosis" models? Isn’t that what "add_category_fields" is for?

Or have I misunderstood its purpose?

t

On Sep 27, 2012, at 1:04 PM, Jose Soares wrote:

Can you try just running ./manage.py syncdb --migrate.


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub.

from django-categories.

tereza avatar tereza commented on August 20, 2024

I do see the category model, but I'm not actually using the category app, Instead I intend to use my Audience and Diagnosis classes based on CategoryBase. In an early attempt to get past this error, I added categories to INSTALLED_APPS in addition to categories.editor. At least I could test whether it would create an intermediate table. It did. So I expected add_category_fields to do the same for my CategoryBase based models as well. But...

from django-categories.

coordt avatar coordt commented on August 20, 2024

Ok, I think I understand now.

The CATEGORIES_SETTINGS only impacts the categories app. It does nothing for subclasses of CategoryBase.

Assuming that the ResourceEntry is one of your models, you can add the custom admin classes for audience and diagnosis to the ResourceEntry admin inlines.

If you can't modify ResourceEntry's admin class, I can tell you how to do it dynamically, like categories does, but it is more complex.

Corey

On Sep 27, 2012, at 2:25 PM, Tereza Snyder [email protected] wrote:

I do see the category model, but I'm not actually using the category app, Instead I intend to use my Audience and Diagnosis classes based on CategoryBase. In an early attempt to get past this error, I added categories to INSTALLED_APPS in addition to categories.editor. At least I could test whether it would create an intermediate table. It did. So I expected add_category_fields to do the same for my CategoryBase based models as well. But...


Reply to this email directly or view it on GitHub.

from django-categories.

tereza avatar tereza commented on August 20, 2024

Aha! That explains it. I was so looking for a way to attach different sets of categories to the SAME model that I willfully misread the docs.

I am trying mightily to keep my ResourceEntry model self-contained. I would really appreciate directions for how to keep it that way.

t

from django-categories.

coordt avatar coordt commented on August 20, 2024

Ok, You'll have to do some copying and pasting from the categories app.

In categories.registration has the basic code for modifying other apps, if you want to browse it.

  1. Basically, you need to create an instance of a ManyToManyField, as if it were part of a model.

field = models.ManyToManyField(Audience)

  1. Then call the field's contribute_to_class to add it to the ResourceEntry model

field.contribute_to_class(ResourceEntry, 'audience')

  1. Then you'll need to modify the ResourceEntry's admin class. For that, it will be easier to create a new one and swap it out.

class NewResourceAdmin(admin.ModelAdmin):
inlines = [AudienceInline,]

admin.sites.unregister(ResourceEntry)
admin.sites.register(ResourceEntry, NewResourceAdmin)

I hope this is enough for you to go on. Let me know if you need more help.

Corey

On Sep 27, 2012, at 2:44 PM, Tereza Snyder [email protected] wrote:

Aha! That explains it. I was so looking for a way to attach different sets of categories to the SAME model that I willfully misread the docs.

I am trying mightily to keep my ResourceEntry model self-contained. I would really appreciate directions for how to keep it that way.

t


Reply to this email directly or view it on GitHub.

from django-categories.

tereza avatar tereza commented on August 20, 2024

Thanks. I look forward to conquering this. And if there's really is a bug in add_category_fields, at least I unearthed it for you ;-).

If I succeed, I'll write it up for the docs.

from django-categories.

coordt avatar coordt commented on August 20, 2024

That would be wonderful. Let me know if you need anything

Sent from my iPhone

On Sep 27, 2012, at 3:25 PM, Tereza Snyder [email protected] wrote:

Thanks. I look forward to conquering this. And if there's really is a bug
in add_category_fields, at least I unearthed it for you ;-).

If I succeed, I'll write it up for the docs.


Reply to this email directly or view it on
GitHubhttps://github.com//issues/57#issuecomment-8952743.

from django-categories.

rmaceissoft avatar rmaceissoft commented on August 20, 2024

something new on this issue?

from django-categories.

variable avatar variable commented on August 20, 2024

i have fallen into the same problem as the original poster, I don't want to modify the 3rd party app but would like to add categories relationship to it.

from django-categories.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.