Hello,

I'm trying to create a model here for essentially recording the
positions held by members in the committee of a university club I'm
creating a website for.

However, I'm new to django and am having some issues.

So far, I have :

A Committee model containing a year and a set of members (committee
can change from year to year)

Each member has a name, what degree they're in, a description of them
and a set of positions they've held. (position in the committee for
each member can change from year to year)

Each position has the year and type of position

and the type of position has a title and a description.

which results in the followiing code in my models.py

class Committee(models.Model):
        year = models.IntegerField()
        members = models.ForeignKey('Member')

class Member(models.Model):
        name = models.CharField(max_length=50)
        degree = models.CharField(max_length = 50)
        desc = models.TextField()
        position = models.ForeignKey('Position')
        
class Position(models.Model):
        year = models.IntegerField()
        pos_type = models.OneToOneField('PositionType')
        
class PositionType(models.Model):
        title = models.CharField(max_length=50)
        desc = models.TextField()

Then in my admin.py, I have the following for the member interface

class MemberAdmin(admin.ModelAdmin):
        fieldsets = [
                (None, {'fields':['name', 'degree', 'desc']})
        ]
        
admin.site.register(Member, MemberAdmin)

Then when I add a member, I get an error page saying
"main_member.position_id may not be NULL"

as well as this, if I then try and add the ability add positions by doing :

class positionInline(admin.TabularInline):
    model = Position
    extra = 3

class MemberAdmin(admin.ModelAdmin):
        fieldsets = [
                (None, {'fields':['name', 'degree', 'desc']})
        ]
        inlines = [positionInline]

admin.site.register(Member, MemberAdmin)

then when I try and add a member, I get an error saying
"<class 'cec.main.models.Position'> has no ForeignKey to <class
'cec.main.models.Member'>"


If anyone could help me try and figure out how to make this work, that
would be greatly appreciated :)

Thankyou

Regards
Stephen

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to