ValueError: invalid literal for int() with base 10:

You must supply a user when you create a department. You can access the current user as request.user if you are in a view

user = request.user 

or fetch any user from the database if you are testing in the shell

user = User.objects.get(id=1) # get 

then create the department:

department = Department(name="test",

Finally, your is incorrect. For a user instance you can access, but the class attribute is not pk of the current user as you might think it is.

Browse More Popular Posts

Leave a Comment