Closed AlexMcBex closed 1 year ago
In Your views.py wherever you have that create for Art, make sure inside your form you have:
form.instance.user = self.request.user # form.instance is the art
all I have in views.py is the CreateView class
class ArtCreate(CreateView):
model = Art
fields = ['title', 'type', 'method', 'comment', 'description']
should I import form?
Yeah I'm thinking in the same way we did with cat collector
still gives me the same error
Did you recently add users to your model or did you always have them?
I added it after... :')
NOOOOOOOOOOO
Try dropping your database then
Like... how? T-T
One thing you can try is deleting all your migration files except for __init.py__
and make a new database as well as update the database name in your settings.py
and then re run make migrations
OK, It works now, thank you :')
What stack are you using?
(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)
Django + SQL
What's the problem you're trying to solve?
I have some problems with some models, I don't know what default should I pick for a new User field to make it be the logged in user by default. same thing to make a created_date field
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
What is your best guess as to the source of the problem?
something to do with the session maybe
What things have you already tried to solve the problem?
for the User I've put None as default but it's not what I wanted, for date I imported from django.utils.timezone now and set it as default but since I can't migrate I'm not sure it's working atm
Paste a link to your repository here https://github.com/AlexMcBex/Xketchez