OdifYltsaeb / django-multilingual

Automatically exported from code.google.com/p/django-multilingual
MIT License
0 stars 0 forks source link

fk_name 'master' is not a ForeignKey to <class [...]> #107

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I saw other reports on this issue but none helped me fix the situation, so
here's the problem:

What steps will reproduce the problem?
1. Import the "tasks" module inside django app (code follows)
2. Fire up the admin and try to add a new TodoItem

What is the expected output? What do you see instead?

Expected: element add form
Instead: stack trace

Exception at /admin/tasks/todoitem/add/

fk_name 'master' is not a ForeignKey to <class 'wedsite.tasks.models.TodoItem'>

Request Method:     GET
Request URL:    http://localhost:8000/admin/tasks/todoitem/add/
Exception Type:     Exception
Exception Value:    

fk_name 'master' is not a ForeignKey to <class 'wedsite.tasks.models.TodoItem'>

What versions of django and multilingual are you using? On what operating
system?
multilingual trunk, latest revision, django 1.0.4, python 2.4, Windows 7 RC1

Please provide any additional information below. (Module code follows)

*** models.py ***
from django.db import models
import multilingual

class TodoList(models.Model):
    slug = models.SlugField(max_length=50, primary_key=True)
    class Translation(multilingual.Translation):
        description = models.TextField(max_length=1000)
    def __unicode__(self):
        return self.slug

class TodoItem(models.Model):
    parent_list = models.ForeignKey(TodoList)
    done = models.BooleanField(null=False, default=False)
    class Translation(multilingual.Translation):
        item_body = models.TextField(max_length=100)
    def __unicode__(self):
        return self.item_body

*** admin.py ***

import models
from django.contrib import admin
import multilingual

class TodoListAdmin(multilingual.ModelAdmin):
    list_display = ('slug', 'description')

class TodoItemAdmin(multilingual.ModelAdmin):
    list_display = ('item_body',)

admin.site.register(models.TodoList, TodoListAdmin)
admin.site.register(models.TodoItem, TodoItemAdmin)

Original issue reported on code.google.com by gabriele...@gmail.com on 27 Nov 2009 at 1:32

GoogleCodeExporter commented 8 years ago
update:
if I change the module name from "tasks" to "activities", without changing 
anything
else, the admin works fine.
Looks to me like there's some sort of order issue (perhaps if the module name 
starts
with a t and/or comes after the sites module on the admin?)
I have no idea. I hope this is useful to someone.

Original comment by gabriele...@gmail.com on 27 Nov 2009 at 1:48

GoogleCodeExporter commented 8 years ago
Multilingual currently works in way, that every Translated model has to have 
its own
ModelAdmin class. It does not have to do anything new, it just must exist. Then
everything is all right.

Original comment by vlastimi...@gmail.com on 12 Apr 2010 at 2:45