Django : OperationalError no such column: Utilisateurs_videos.user_id - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html) +--- Thread: Django : OperationalError no such column: Utilisateurs_videos.user_id (/thread-32978.html) |
Django : OperationalError no such column: Utilisateurs_videos.user_id - Adem - Mar-20-2021 Hi, I'm struggling with a problem for a week now. I can't make a relation between the user and the uploaded video. When I get the user = models.Foreignkey off, it works but the videos are public and not ony to the user. I tried to run makemigrations and all the stuff but nothing works : even when i try to access the DB from the admin page, it makes this error: OperationalError no such column: Utilisateurs_videos.user_id Could someone help me on this one ? Thanks! : Here are forms.py and models.py: from django.db import models from django.conf import settings from .validation_taille import validate_file_extension # Create your models here. class Videos(models.Model): user=models.ForeignKey(settings.AUTH_USER_MODEL,default=1,on_delete=models.CASCADE) caption=models.CharField(max_length=100) Video=models.FileField(upload_to='video/%y',validators=[validate_file_extension]) def __str__(self): return self.caption from django import forms from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm from .models import Videos class UserRegisterForm(UserCreationForm): class Meta: model=User fields=['username','password1','password2'] class AuthenticationForm(forms.Form): username = forms.CharField(widget=forms.TextInput( attrs={'class': 'form-control','type':'text','name': 'username','placeholder':''}), label='Utilisateur') password = forms.CharField(widget=forms.PasswordInput( attrs={'class':'form-control','type':'password', 'name': 'password','placeholder':''}), label='Mot de Passe') class Meta: model=User fields = ['username', 'password'] class Video_Form(forms.ModelForm): class Meta: model=Videos fields=('caption','Video') |