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')
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)
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, related_name='attendees')
PlusOne = models.ForeignKey(User, on_delete=models.CASCADE, related_name='PlusOne')
class Meta:
unique_together = (('events', 'attendees'),)
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
extra = 1
class EventsAdmin(admin.ModelAdmin):
inlines = [ AttendInline, ]
admin.site.register(Events, EventsAdmin)
--
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...@googlegroups.com.
To post to this group, send email to django...@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/690d5956-6348-4ae3-99bf-030e7df91cdb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.