Skip to content
Snippets Groups Projects
Commit bcc12038 authored by Rafael László's avatar Rafael László :speech_balloon:
Browse files

removed mentor foreign key

parent fd701ee7
No related branches found
No related tags found
1 merge request!2Dev
# Generated by Django 2.2.4 on 2020-02-09 22:52
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('mentors', '0002_auto_20200209_1955'),
]
operations = [
migrations.RemoveField(
model_name='mentor',
name='mentor',
),
]
import os import os
from django.db import models from django.db import models
from account.models import Profile
from django.dispatch import receiver from django.dispatch import receiver
class Mentor(models.Model): class Mentor(models.Model):
mentor = models.ForeignKey(
Profile,
related_name="mentor",
on_delete=models.DO_NOTHING,
)
name = models.CharField(null=False, max_length=200) name = models.CharField(null=False, max_length=200)
text = models.TextField() text = models.TextField()
image = models.ImageField( image = models.ImageField(
......
...@@ -3,16 +3,11 @@ from rest_framework import serializers ...@@ -3,16 +3,11 @@ from rest_framework import serializers
class MentorSerializer(serializers.ModelSerializer): class MentorSerializer(serializers.ModelSerializer):
mentor = serializers.SerializerMethodField()
class Meta: class Meta:
model = Mentor model = Mentor
read_only_fields = ('mentor', )
fields = '__all__' fields = '__all__'
def get_mentor(self, obj):
return obj.mentor.full_name
def to_representation(self, instance): def to_representation(self, instance):
response = super( response = super(
MentorSerializer, MentorSerializer,
......
...@@ -12,10 +12,3 @@ class MentorsViewSet(viewsets.ModelViewSet): ...@@ -12,10 +12,3 @@ class MentorsViewSet(viewsets.ModelViewSet):
IsStaffOrStudent, IsStaffOrStudent,
) )
queryset = Mentor.objects.all().order_by('name') queryset = Mentor.objects.all().order_by('name')
def perform_create(self, serializer):
kwargs = {
'mentor': self.request.user.profile
}
serializer.save(**kwargs)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment