Skip to content
Advertisement

Tag: django-models

Automatic avoidance of category duplicates

I have the problem with Category Model. I have 2 tables: so they are standard models with categories. User can create Category by creating a movie with the name of category additionaly. The problem is when user is trying to create Movie with category name that already exists, because it will create another category with the same name (like duplicate)

How to create and save that file to Django model?

I want to create a file and save it to Django model within a view without creating any temporary files or anything like that. I plan to write a .txt file that contains information and I want to save the .txt file in the Django model. Does anyone know how to do this? Thank you Answer Yes – ContentFile. Assuming

OperationalError at / no such table: users_user

I had a model Profile which was an extension to my User model which was the ForeignKey of my Post model, but I changed it to an AbstractUser and now if I try migrating or running and refreshing the page the server I get an error. models.py settings.py error message after I try migrating Answer I easily solved it by

How do I solve django.db.utils.IntegrityError: UNIQUE constraint failed?

How do I solve django.db.utils.IntegrityError: UNIQUE constraint failed? error code is django.db.utils.IntegrityError: UNIQUE constraint failed: Movies_comment.user_id, Movies_comment.tv_or_movie_id. This error occurs Comment(comment=form.cleaned_data[“comment”],user=request.user,stars=form.cleaned_data[“stars”],tv_or_movie=tv_or_movie_object).save() views.py models.py helper_views.py Answer tv_or_movie before saving i.e.

Advertisement