Hi,

Here's a hack that might solve your problem.

# moduleApp/admin.py
class ModuleAdmin(admin.ModelAdmin):
    inlines = []
    # etc

admin.site.register(Module, ModuleAdmin)


# articleApp/admin.py
from moduleApp.admin import ModuleAdmin

class ArticleInline(admin.StackedInline):
    model = Article
    # etc

ModuleAdmin.inlines.append(ArticleInline)

Collin

On Friday, November 21, 2014 12:22:04 AM UTC-5, [email protected] wrote:
>
> I have a <article> model that has a foreignKey to a <module> model.  I 
> want to be able to edit the <module> model within the <article> admin
>
> in moduleApp.models I have something like:
> class module(models.Model):
>   HTML = models.TextField( blank=True, null=True )
>
> in articleApp.models I have something like:
> class article(models.Model)
>   HomePageModule = models.ForeignKey(module, blank=True, null=True)
>
> In the admin I have something:
> class moduleInline(admin.TabularInline):
>     model = module
>
> class ArticleAdmin(admin.ModelAdmin):
>     inlines = [moduleInline,]
>     
> I'm getting the error XXX has no ForeignKey to XXX.
>
> I've found a few other people with the problem and it seems like the 
> problem is that I need to change up the moduleInline to articleInline.
>
> http://stackoverflow.com/questions/21899523/inline-in-django-admin-has-no-foreignkey
>
> http://stackoverflow.com/questions/8526159/django-inline-has-no-foreignkey-to
>
> I'm trying to keep my moduleApp as a stand alone app and use it in 
> multiple other apps.  To achieve this I'll have to move all the admin code 
> in the module app.  This defeats my desire to make moduleApp a stand alone 
> app.  
>
> Is there a way I can make inlines work for this?  If not, what is the best 
> way to get this done?  I've got a highly customized admin so I don't mind 
> making the edits.  
>
> Brian
>
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bb867978-d0fa-4b2d-9e7e-95763b2520ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to