[Python] Django shell: Can't find constructor of a model

Discussão em 'Python' iniciado por Stack, Abril 4, 2025.

  1. Stack

    Stack Membro Participativo

    I have a Django Modell Kunde

    from django.db import models


    class Kunde(models.Model):
    Kundennummer = models.IntegerField(),
    Vorname = models.CharField(max_length=200),
    Nachname = models.CharField(max_length=200)


    I open the Django shell with the command python manage.py shell

    I do

    from kundenliste.models import Kunde;


    and then

    Kunde.objects.all()


    This gives me

    <QuerySet []>


    Now I would like to insert a new customer

    But

    k1 = Kunde(Kundennummer=1,Vorname="Florian",Nachname="Ingerl");


    gives me the error

    Traceback (most recent call last):
    File "<console>", line 1, in <module>
    File "C:\Users\imelf\Documents\NachhilfeInfoUni\MaxPython\env_site\Lib\site-packages\django\db\models\base.py", line 569, in __init__
    raise TypeError(
    TypeError: Kunde() got unexpected keyword arguments: 'Kundennummer', 'Vorname'


    What do I do wrong?

    Continue reading...

Compartilhe esta Página