I want the users, once they are logged in, to be able to add information about their company including website, name, logo, etc.
I already have this model
user = models.ForeignKey(settings.AUTH_USER_MODEL, default=1, unique=True)
comp_name = models.CharField(max_length=120,default='', blank=True)
comp_site = models.URLField(default='', blank=True)
comp_logo = models.ImageField(default='', blank=True, upload_to='img/logos/')
in my views.py I have this:
if form1.is_valid():
saveInfo = form1.save(commit=False)
comp_name = form1.cleaned_data.get("comp_name")
comp_site = form1.cleaned_data.get("comp_site")
comp_logo = form1.cleaned_data.get("comp_logo")
saveInfo.user = form1.user
saveInfo.save()
return redirect('/profil/')
What I'd like is that the program would automatically detects which user is currently logged in, and set the user field to that user.
How could I do this?