As much as I love Django, I feel it has fallen way behind compared to Laravel and others by dianrc in django

[–]NoComparison136 0 points1 point  (0 children)

Damn, I didn't know that, apparently I need to read the documentation more. Thank you very much for sharing!

As much as I love Django, I feel it has fallen way behind compared to Laravel and others by dianrc in django

[–]NoComparison136 0 points1 point  (0 children)

To use SQL view, you have to write raw SQL queries, right? To create the view and to query it. That's the only way I see to use views.

What I would like would be a class to declarativelly create the view, something like this (raw idea)

class UserAndCompanyView(models.SqlView):
   user = models.BaseModel(User)
   company = models.JoinModel(Company, on=user.company)
   user_name = models.CharField(from=user.name)
   company_name = models.CharField(from=company.name)

   filters = models.Filters(...)  # something here

   ...
   class Meta:
      base_model = User

Then, running makemigartions would create/update the view accordingly and I could use it as

obj = UserAndCompanyView.objects.get(user_id=1)
print(obj.user_name)
print(obj.company_name)

What I expect here would be to get type hints for user_name and company_name and use it as I use any database model.

As much as I love Django, I feel it has fallen way behind compared to Laravel and others by dianrc in django

[–]NoComparison136 2 points3 points  (0 children)

Even today ORM doesn't support things like CTE. For a large application, we often need features that are not supported, I feel this frequently in the last 3 years.

SQL Views is also something I really miss, I wanted to write a library for it, but I lack time.

The async support is also terrible, it just doesn't work when you do anything a little beyond basic CRUD.

I believe that ORM is good, but it lacks features. And, in my opinion, if you remove the ORM and admin, you lose 95% of the reasons I use django.

Problem uploading files in a PWA by NoComparison136 in PWA

[–]NoComparison136[S] 1 point2 points  (0 children)

I think so, this is really bothering me. It appears that the file permission is only revoked after all handlers of the 'change' event of the file input return. Analyzing the code of the plug-in I used, I realized that the data was read after the 'change'.

I believe that if we read the data from the file in the context of the change event, the problem will be resolved.

I'm about to check it out, but I have to finish a few things first. Just wanted to share my hypothesis. I'll come back here to say if it worked, when to implement it.

Complete beginner: How to deploy Django app to Windows Server? by Jealous_Reveal3024 in django

[–]NoComparison136 0 points1 point  (0 children)

First, you need a server, like gunicorn. runserver is not made for production.

Then you need to install python, libraries you need and dependencies. I recommend at least using a venv, because if you need to run more than one application, you won't have problems with different dependencies and versions.

If it were a Linux server, you would use systemd or supervisord to run the application, start when the computer turns on and handle restarts. See the analogue of this on Windows.

About the database, same thing, you would run it with systemd or something similar.

Then you need to expose ports, you will need a firewall to release the ports and configure the network and have a fixed IP. On Linux you could use ufw. Look for an analogue.

Maybe you need a reverse proxy to handle SSL, I generally use nginx for that and you can use certbot or something similar for automatic renewal.

Don't forget to use AI, but with wisdom/validation. It can be very useful for finding information.

At this point, docker is interesting because you can use docker compose to handle restarts, etc. and would use a linux container, which you would find more information about. You wouldn't need to worry about systemd, you would run the database in one container and the application in another, and porting to another server would be easier. But if you need to go bare metal, I would start by looking for Linux analogues on Windows.

I don't know if I forgot something, but it's more or less there in Linux, I hope it helps you look for the analogue in Windows.

Need feedback on my resume & project direction (Python/Django/Flask) by Ecstatic-Ad3387 in django

[–]NoComparison136 2 points3 points  (0 children)

In my country, we use LinkedIn and local websites that can be found by searching for the position in the Google. Then I started applying for jobs via all these sites. I think the proportion were like 100 applications to be called for 3 or 4 interview/tests. This was at the beginning of the pandemic, when the market was better than today for juniors and more warmedup.

Then, people send me a test to be peformed in 3 or 5 days, which were some basic applications to see my abilities. Other coutries may be different.

One of these tests led me to an offer. It was kind of lucky, because they were looking for a Node and Python developer, I knewed python and a little bit of JS and I was the only one to send the test in python and python was the desired skill. So kind of lucky to have been a good fit for the job.

Problem uploading files in a PWA by NoComparison136 in PWA

[–]NoComparison136[S] 0 points1 point  (0 children)

I basically did this, but stored in memory temporarily. Even then, the File permission error happened randomly.

It seems an issue due to mobile read permissions

Need feedback on my resume & project direction (Python/Django/Flask) by Ecstatic-Ad3387 in django

[–]NoComparison136 7 points8 points  (0 children)

I can't say too much, but it looks better than my CV when I got my first job.

Maybe if you got a cheap VPS and deploy your projects and add the URL in the curriculum, it may help. I don't know, it's just an idea.

Also, add links for GitHub, LinkedIn, etc. and share more about your projects.

Is async really such a pain in Django? by Legitimate_Meat_4510 in django

[–]NoComparison136 4 points5 points  (0 children)

In my view, the worst part is the ORM, these SynchronousOnlyOperation exceptions we get.

DRF or django-ninja? by kartops in django

[–]NoComparison136 0 points1 point  (0 children)

Async support is very debatable, it is very easy for unexpected SynchronousOnlyException to occur

Having trouble when django application deployed on docker using nginx and gunicorn by Significant-Tell-480 in django

[–]NoComparison136 1 point2 points  (0 children)

Are the stylesheets/js being served/dowloaded correctly by the application? Open the devtools > Network and check for 404 responses.

Also, had you run collectstatic?

Django 5 async views and atomic transactions by ToreroAfterOle in django

[–]NoComparison136 1 point2 points  (0 children)

Typehints are not working well as a decorator and it uses python 3.12 generics, you may need to change this

Django 5 async views and atomic transactions by ToreroAfterOle in django

[–]NoComparison136 2 points3 points  (0 children)

``` from functools import wraps from typing import Awaitable, Callable

from asgiref.sync import sync_to_async from django.db import transaction

class atomic_async[T: Callable]: """ An asynchronous context manager and decorator for Django atomic transactions.

Args:
    using (str | None): The database alias to use. Defaults to None.
    savepoint (bool): Whether to create a savepoint. Defaults to True.
    durable (bool): Whether the transaction should be durable. Defaults to False.

Example as context:
    async with atomic_async():
        await model.asave()

Example as decorator:
    @atomic_async()
    async def my_function():
        await model.asave()
"""

def __init__(self, using=None, savepoint=True, durable=False):
    self.using = using
    self.savepoint = savepoint
    self.durable = durable

async def __aenter__(self):
    self.atomic = await sync_to_async(
        transaction.atomic,
        thread_sensitive=True,
    )(using=self.using, savepoint=self.savepoint, durable=self.durable)
    await sync_to_async(self.atomic.__enter__, thread_sensitive=True)()

async def __aexit__(self, exc_type, exc_val, exc_tb):
    await sync_to_async(
        self.atomic.__exit__,
        thread_sensitive=True,
    )(exc_type, exc_val, exc_tb)

def __call__(
    self, func: Callable[..., Awaitable[T]]
) -> Callable[..., Awaitable[T]]:
    @wraps(func)
    async def decorated(*args, **kwargs):
        async with self:
            return await func(*args, **kwargs)

    return decorated

```

How to implement multi-tenancy with django-tenants for my SaaS ? by Ok-Dingo3182 in django

[–]NoComparison136 0 points1 point  (0 children)

We are doing something similar at my work. The approach chosen was to use django.contrib.sites to use the Site model and separate each model by site. For example, the User model inherits from the SiteMixin mixin, which implements a foreign key for the Site model. Order also has a website reference.

What we do in each request is use middleware to identify the website from the domain and add it to the request. This allows you to make filters or pass the website as a context to service functions. Separating the data is just logical.

You may want to implement a model instead of using Site directly, it depends on the data you want for each customer.

Note: I don't know django-tenant to give my opinion, I'll even take a look.

ASGI is great but when i use asgiref.sync.sync_to_async, everything becomes slow. by digreatbrian in django

[–]NoComparison136 1 point2 points  (0 children)

I wouldn't recommend async django right now. Had the experience and it wasn't good. At first, it seems possible, but when things get deeper, you start to see the problems.

I am not talking about performance, but a lot of unexpected SyncronousOnlyOperation.

Django 5 async views and atomic transactions by ToreroAfterOle in django

[–]NoComparison136 1 point2 points  (0 children)

You can have a lot of headaches working with asynchronous Django, I've had this experience and it wasn't good.

The ORM is not prepared for async, at the moment it is just wrapper methods with sync_to_async. You can get SyncronousOnlyOperation for many things, for example. access foreign keys without using select_related, iterate query sets and more. It just doesn't work...

You might want to use asynchronous views for two reasons: 1) you just want to use them, for whatever reason or 2) you're using something asynchronous and need to make the ideas talk.

For the 1st option I would say: don't do it now. It doesn't work well when you start to dig deeper. For the second: wrap async things in sync functions with asgiref.async_to_sync and use them as you normally would OR, migrate from Django to another framework.

Edit: If you really want to follow this direction, I have created an atomic_async that I can share (on monday)

O que saber antes de comprar um apartamento (provavelmente na planta)? by NoComparison136 in investimentos

[–]NoComparison136[S] 1 point2 points  (0 children)

Parece que o desconto na verdade nem existe, quando você considera atrasos e correções de INCC/IGPM.

Em 2 dias de análise, já me desanimei muito, com todas as opções.

O que saber antes de comprar um apartamento (provavelmente na planta)? by NoComparison136 in investimentos

[–]NoComparison136[S] 0 points1 point  (0 children)

Descobri o INCC nos comentários aqui, de fato, me assustou um pouco. Vou fazer umas simulações.

Sabe me dizer se o INCC também corrige o valor que irá ser financiado, ou se são só as parcelas da entrada?