Where should data validation happen? – Model or Serializer?
I am working on a project where data validation is crucial. I have noticed tutorials placing validation logic either on the data model itself or within a separate serializer class. This inconsistency is causing confusion.
Can you clarify the pros and cons of each approach for data validation, and when it might be better to use one over the other?
How to Resolve HttpRequest AssertionError in Django Friend Request View?
I’m working on a Django project where users can send and accept friend requests. When a friend request is accepted, I want to add the sender and receiver to each other’s friend list and send a notification. However, I’m encountering an error when trying to send the notification.
Django: how to create a unique instance of one model as a field in another model
I am trying to store an instance of an items model as a field in my users model using ForeignKey like so:
How to create different sizetables for each type of clothing?
Im making shop on django and cant realize how to solve the problem:
I got class Product(class for clothes) and i need to create another class for Sizes of different categories of clothes, for example:
Shoes will got – 9US, 10US, 11US…
Shirts will got – XS, S, M, L…
etc.
How can i create that type of class??
My Product class:
django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model ‘tools.User’ that has not been installed
I want to replace the original User of django with my own User, but the following error occurred there is my settings.py,I mainly addedAUTH_USER_MODEL = ‘tools.User’ from datetime import timedelta from pathlib import Path import django DEBUG = True ALLOWED_HOSTS = [] INSTALLED_APPS = [ ‘channels’, “daphne”, ‘django.contrib.admin’, ‘django.contrib.auth’, ‘django.contrib.contenttypes’, ‘django.contrib.sessions’, ‘django.contrib.messages’, ‘django.contrib.staticfiles’, ‘rest_framework_simplejwt’, ‘corsheaders’, […]