Python Forum
Django : OperationalError no such column: Utilisateurs_videos.user_id
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Django : OperationalError no such column: Utilisateurs_videos.user_id
#1
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')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Flask: sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked pythonpaul32 1 2,029 Apr-04-2023, 07:44 AM
Last Post: Larz60+
  Django: How to automatically substitute a variable in the admin page at Django 1.11? m0ntecr1st0 3 3,246 Jun-30-2019, 12:21 AM
Last Post: scidam
  django-geoposition and unknown column error? PrateekG 3 3,834 Jun-26-2018, 11:56 AM
Last Post: PrateekG

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020