Category : django-rest-framework

I have build my frontend using Angular and backend using django-restframwork. In my settings.py I provided CORS_ORIGIN_ALLOW_ALL = True I run it using python3.8 manage.py runserver 5000 but when my frontend tried to send request to it it generates error. my angular sends request like this. my environment file where I saved my urls export ..

Read more

I’m trying to migrate my coustom user model but when i run makemigrations command that makes new models for migration. But when i run migrate command it throws error : django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency accounts.0001_initial on database ‘default’. traceback Traceback (most recent call last): File "manage.py", line 22, in <module> main() ..

Read more

I am pretty new to the django_restframework. I want to be able to delete users from the database when a DELETE request comes in. Here is my Views: class RetrieveUsersView(generics.ListCreateAPIView): """Retrieves all Users""" serializer_class = UserSerializer authentication_classes = (authentication.TokenAuthentication,) permission_classes = (permissions.IsAuthenticated,) queryset = get_user_model().objects.all() Here is my Serializer: class UserSerializer(serializers.ModelSerializer): """Serializer for the users ..

Read more

I’m trying to attach an image in a email that i send in a task with celery Im working with Django Rest Framework This are my task.py from celery import shared_task from email.mime.image import MIMEImage from django.contrib.staticfiles import finders from django.template.loader import get_template from django.core.mail import EmailMultiAlternatives @shared_task def send_new_dispatch_guide_email_task(**kwargs): subject = kwargs[‘subject’] from_email = ..

Read more

In Django Rest Framework I have this serializer: class RecipeSerializer(serializers.ModelSerializer): user = UserSerializer(read_only=True, many=False) id = serializers.ReadOnlyField() ingredients_list = IngredientCompositionSerializer(read_only=False, many=True) def create(self, validated_data): validated_data[‘user’] = self.context[‘request’].user return super().create(validated_data) class Meta: model = Recipe fields = [‘user’, ‘id’, ‘name’, ‘description’, ‘ingredients_list’, ‘created’, ‘modified’] In his ViewSet, when I try to create a new Recipe, I ..

Read more