Hello,

I'm new to Django and i'm trying to made a simple app in which users can 
attend to an event. I'm trying to have this manageable through the admin 
site but i get the following error :
<class 'evenement.admin.AttendInline'>: (admin.E202) fk_name 'attendees' is 
not a ForeignKey to 'evenement.Events'.

My goal is to have an interface to create the event and add users in the 
event.

Here are my models :

from django.db import models
from django.contrib.auth.models import User


# Create your models here.
class Events(models.Model):
 Name = models.CharField(max_length=64)
 Date = models.DateTimeField()
 Description = models.CharField(max_length=200)
 Admin = models.ForeignKey(User, models.SET_NULL, blank=True, null=True, 
related_name='event_admin')
 Status = models.PositiveIntegerField(default=0)
 Attendees = models.ManyToManyField(User, through='Attend',through_fields=(
'events','attendees'))
 
 def __str__(self):
 return self.Name


class Attend(models.Model):
 events = models.ForeignKey(Events, on_delete=models.CASCADE)
 attendees = models.ForeignKey(User, on_delete=models.CASCADE)
 PlusOne = models.ForeignKey(User, on_delete=models.CASCADE, related_name=
'PlusOne')

And the admin.py

from django.contrib import admin
from .models import Events
from .models import Attend
from django.contrib.auth.models import User




# Register your models here.


class AttendInline(admin.TabularInline):
 model = Attend
 fk_name = "attendees"
 extra = 1


class UserAdmin(admin.ModelAdmin):
 inlines = [ AttendInline, ]


class EventsAdmin(admin.ModelAdmin):
 inlines = [ AttendInline, ]




admin.site.unregister(User)
admin.site.register(User, UserAdmin)


admin.site.register(Events, EventsAdmin)


Your help will be much appreciated !

Thank you

Vincent

-- 
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 django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a4b011b0-49b0-47d7-a4cd-1d4663cc4aa0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to