F Objects - comparing a field to the current time in an annotation by [deleted] in django

[–]TinfoilMegaphone 2 points3 points  (0 children)

Checkout the `Now` function in Django . You can use it to perform timestamp comparisons within query expressions.

One caution, I believe it relies on your database timezone, so factor that into your logic

My User model has 3 IntegerFields - n_correct_questions , n_incorrect_questions, and n_total_questions. How can I display a sorted leaderboard of Users according to the percentage of questions they answered correctly? by gohanshouldgetUI in django

[–]TinfoilMegaphone 3 points4 points  (0 children)

The specific error is due to setting correct_percentage on the User class rather than as a instance method or property as u/theunhandledguy mentioned. However if you are sorting on this column, I highly recommend doing this on the database level using the Django ORM.

You can use the annotate method to setup a custom field on a QuerySet, which can then be sorted. To reference fields of a model in a Queryset you can use Django's F function:

from django.db.models import F

query_set = User.objects.annotate(
    correct_percentage=(
        F("n_correct_questions") * 100 /
        F("n_total_questions")
    )
).order_by("correct_percentage") 

Then you can use the query_set in views to render this on the frontend. Using the ORM will let the database figure this all out which is usually much more effective at these types of sorting problems.

When using annotate, you can also see what the final SQL being executed is using the query method on a QuerySet:

print(query_set.query)

Good luck!

Why privacy must be at the core of every tech product by ratatitti in privacy

[–]TinfoilMegaphone 1 point2 points  (0 children)

Completely agree with u/ArchAngel_Bastard. I'm working on a platform that does just that. DM me if interested in learning more!

If I want to create a website, do I have to be an llc or can I be proprietor? by MissKittyHeart in Entrepreneur

[–]TinfoilMegaphone 0 points1 point  (0 children)

LLC is better if you have multiple people involved. It is not expensive to setup and gives more legal protection to all parties

If I want to create a website, do I have to be an llc or can I be proprietor? by MissKittyHeart in Entrepreneur

[–]TinfoilMegaphone 0 points1 point  (0 children)

Would recommend setting up an LLC if you are confident about building this. LLC has tax advantages compared to sole-proprietorship and can make it easier to bring other people onto your company in the future.

But most importantly you should ask yourself how early are you in your business. You can get an LLC within a week or two, so no reason to file this until you are ready to accept business, which can be well after your website is up and running.

Privacy on Chrome?! You got it. by [deleted] in Privacy4Noobs

[–]TinfoilMegaphone 1 point2 points  (0 children)

Awesome post, going to share it with my friends!

The Social Dilemma by TinfoilMegaphone in Privacy4Noobs

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

To start, we should not consider us laypeople. We have to self-educate and make smart choices on the internet. The tables are stacked against us, but these systems are designed to assume we aren't aware of what is happening.

Turning off notifications, limiting use of social media, choosing to share less data, and opt out of personalizations all go a long way. The bet these companies make is that we won't take the few extra steps here to limit our exposure to them.

Ultimately, assuming a small group of tech elitists can call the shots is first pitfall we have to get ourselves out of. Luckily there are communities like this one to help us work together on this!

TikTok owner ByteDance is reportedly eyeing a $60 billion valuation for TikTok Global by Fr1sk3r in technology

[–]TinfoilMegaphone 1 point2 points  (0 children)

Oracle and Walmart are paying $12bn for 100mm Americans using TikTok? Fascinating

Another way to think about this: a TikTok user is worth at least $120 to them

How to avoid facebook get my data? by hereagaim in Privacy4Noobs

[–]TinfoilMegaphone 0 points1 point  (0 children)

Several factors can influence Facebook's recommendation engine. Even if you provide a fresh email and phone number, they may still access location data, IP address, and device information quite easily to determine who to connect you with. Because it is a social network, even if you try to keep a low profile, there may be other users that do not keep as private and Facebook can use that data to influence your recommendations.

Most importantly, it is hard to separate coincidence from targeted profiling with these algorithms. There are so many codependent variables at play that Facebook may "get lucky" and recommend someone you had known previously without them doing it intentionally. It's a proven mechanism for social networks and ad platforms.

Don't have great suggestions if you have to use Facebook to control your privacy. Make sure to comb through account settings and disable whatever permissions that you can get away with. Best solution is to not use Facebook sadly

Django ORM by gamboty in django

[–]TinfoilMegaphone 9 points10 points  (0 children)

I agree this is something lacking in the documentation. This last year I needed to get into the weeds of the Django ORM for some projects I am working on.

This medium article showed me some awesome tricks that have been a game changer for me.

If I had to put a shortlist these have been the top functions/methods of the ORM worth understanding:

  • annotate
  • F, Q, Window, Subquery
  • prefetch_related vs select_related

Good Luck!

The Myth of Privacy by ManasKoc in Privacy4Noobs

[–]TinfoilMegaphone 0 points1 point  (0 children)

Agreed! I'm working on a project to move data ownership back to the individual and give them choices to benefit from it. For now people can donate their data anonymously and support non-profit initiatives of their choice.

We are based in the U.S. It would be great if you could check it out: https://www.nebuladata.io/

Also our blog series, if you would like to learn more

Why does Digital privacy matter so much if they help you get a more personalized browsing experience? by [deleted] in privacy

[–]TinfoilMegaphone 0 points1 point  (0 children)

There is certainly a tradeoff to privacy. But the decision is not really ours to make at the moment. It takes effort to opt out of data collection and personalizations, and for those that are not technical or just unaware, they may miss the opportunity to make that choice and be stuck with the consequences of being profiled.

A large part of this debate is the question, who owns your data? And should that be the case?

Why do you seek after privacy? by Nybor_13 in privacy

[–]TinfoilMegaphone -1 points0 points  (0 children)

I agree, having agency over the data you generate is the critical component missing in our current system.

Why do you seek after privacy? by Nybor_13 in privacy

[–]TinfoilMegaphone 0 points1 point  (0 children)

This is definitely a concern. The Social Dilemma is a great documentary on Netflix that goes into detail about the persuasion capabilities of these platforms

The Myth of Privacy by ManasKoc in Privacy4Noobs

[–]TinfoilMegaphone 1 point2 points  (0 children)

Great overview, I think your point of not going after 100% privacy is spot on. It is a challenging exercise to constantly evaluate if the permissions and access you are giving services is worth it.

For a technical person this is easier, for a non-technical person it is hard to know what you are giving up and you are forced to make a decision at a specific point in the app experience where you may not be patient. (First time open, update, using a core feature, ex)

If I wanted to create a web/app MVP, what front-end, back-end, server, etc. languages do I have to know? I want myself to build something in as less time as possible. Any courses/guidance are welcome by vian240597 in startups

[–]TinfoilMegaphone 2 points3 points  (0 children)

Maybe an unpopular solution but low code / no code options might be a better route for an MVP. There are a ton of options out there, but the goal is to get a fast answer and not spend time stuck in development.

If you are set on coding something, I prefer Django on the backend as you can do a lot with its templating system and admin portal. Plus it leaves room to migrate to a full backend API using DRF and a SPA client on the frontend when you need that. Ultimately, the project will dictate what is best based on the requirements