Categories
Mastering Development

django-private-storage configuration in nginx and Docker

I am trying to use django-private-storage package to protect a model’s file from being accessed or downloaded by users who are not owners of the file. I was able to do it successfully in development (using python manage.py runserver) In development, I am using nginx configured via docker. I can create objects with both FileField […]

Categories
Development

KML file downloaded save to DB in django postgres with framework selenium

I’m doing a project that contains information from a GPS, that when the server is started it downloads all the information with the coordinates of the object to a KML file, but now i can’t save it to a DB in postgres on django. I need that when the files are downloaded that they are […]

Categories
Development

Issue creating a django user with python-social-auth with a custom User model and UserManager

Seems like this isn’t a unique problem, but I’m missing something in the solution. I’m using python-social-auth and logging in with Google. All seems to be going well, until it gets to the create_user part of the pipeline. I do have a custom User model and UserManager. On my User model I do have a […]

Categories
Development

Issue creating a django user with python-social-auth with a custom User model and UserManager

Seems like this isn’t a unique problem, but I’m missing something in the solution. I’m using python-social-auth and logging in with Google. All seems to be going well, until it gets to the create_user part of the pipeline. I do have a custom User model and UserManager. On my User model I do have a […]

Categories
Development

Django Update Method for Viewset returning 415 even after overwritting it

Right now I am learning to create REST API with Django, but am struggling to implement the Update method. My tests always fail and I am not sure if it is because of the serializer or something else. Would appreciate some quick feedback for my code! class Company(models.Model): owner = models.ForeignKey(User, on_delete=models.CASCADE) name = models.CharField(max_length=50) […]

Categories
Development

Filter objects with Rest Framework Django API

I have a model Person in Django class Language(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=50) def __str__(self): return self.name class Country(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) name = models.CharField(max_length=50) def __str__(self): return self.name class Person(models.Model): PersonId= models.UUIDField( primary_key=True, default=uuid.uuid4, editable=False) Countries = models.ManyToManyField(Country) Languages = models.ManyToManyField(Language) each person can have (visit) many countries […]

Categories
Development

Create object only if other object is successfully created

I am fairly new to Django and unfamiliar with the best practices for this situation (in any framework/language, not just python/django). The situation is that when a user first registers on my site, I want to create an “organization” for them if it doesn’t exists, and then subsequently create a user for them, which references […]

Categories
Development

Create object only if other object is successfully created

I am fairly new to Django and unfamiliar with the best practices for this situation (in any framework/language, not just python/django). The situation is that when a user first registers on my site, I want to create an “organization” for them if it doesn’t exists, and then subsequently create a user for them, which references […]

Categories
Development

Error in django when creating an instance of inlineformset_factory

I created two models: primary and secondary with one-to-many relationship. Then I created a formset using inlineformset_factory. Then (in a view) I created an instance of that variable with the argument instance. But when I do that, this is the error I get: Error: Traceback (most recent call last): File “…\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\handlers\exception.py”, line 34, in inner […]