I have 2 models(Model Projects and Model Variables) in two apps (Projects app and Variables app). The models are not related in any ways. I want to set the default value in Projects with value in Variables
Model Projects:
class Projects(models.Model):
completion_time = models.FloatField(default='0')
Model Variables:
class Variables(models.Model):
user_var_id = models.OneToOneField(User, null=True, blank=True, on_delete=models.CASCADE)
internal_completion_time = models.FloatField(default='0')
I want users to set a value in the variables and when they create a new project they would have that value from the variables be set as a default value for a new project by default. eg how could i do something like this
variable = Variables.Objects.Get(user_var_id=current_user_id-that i dont know how to get)
class Projects(models.Model):
completion_time = models.FloatField(default=variable.internal_completion_time )
I thought it could be done by adding dynamically the default value, querying the variables filtering for the user and adding the value to the model but i dont know how to get the current user id on the model.py page. How can i do this maybe with another method.