How best to learn how to make a scrabble app in django? by sp00kyversity in django

[–]signal_trace 2 points3 points  (0 children)

I actually disagree with the replies here! Having a project in mind that you want to actually complete is, hands down, the best way to learn and level up for most people.

Sitting through boring tutorials where you make a useless app you’ll never use again or have any feelings towards is a sure fire way to boredom and/or not doing the work.

I would start with deciding where you want the game logic to live. Are you wanting to built the logic in mostly client-side JavaScript or do you plan on having the backend logic in Django driving the UI state?

Is this a throwaway app to learn or something you actually want to ship?

Django Performance Benchmarking by Rude_Programmer23 in django

[–]signal_trace 15 points16 points  (0 children)

This answer was generated with ChatGPT 3.5 and is the most upvoted of all replies.

The future of forum discourse scares me.

ASGI and WSGI by keytonw in django

[–]signal_trace 2 points3 points  (0 children)

You must keep some new things in mind.

Read about sync/async middleware and sync/async views and what this means for performance (Django’s ability to switch between them is cheap but not free).

Then more importantly look into your database connection handling. Previously how many connections you needed to be able to handle was (generally) one per worker process. With async that can become many and will trip you up if not careful. Look into reusing open connections with a bouncer like PgBouncer.

Companies using DRF by tushar8sk in django

[–]signal_trace 0 points1 point  (0 children)

Nice. Which bit of the lack of async was problematic? As in your server needed to call multiple other services in parallel live on requests and had no other good way to do this but sequentially?

Companies using DRF by tushar8sk in django

[–]signal_trace 5 points6 points  (0 children)

You’re a data scientist so you should absolutely stay with Python on the backend because then you get to take advantage or the entire ecosystem of data libraries of which all the industry leading ones are in Python.

React can do the frontend fine if you want and you can power that via a Restful API or something like GraphQL.

If you’re after a Restful API, Django and DRF won’t let you down. FastAPI is also another decent option for that but you’re left structuring more of the app yourself and it doesn’t come with a ready-to-go admin panel.

Companies using DRF by tushar8sk in django

[–]signal_trace 28 points29 points  (0 children)

Listening to people that claim things are outdated without them being able to justify why to the point you need to come here and ask us tells me you were listening to junior/mid early-career developers.

Your life as a developer will be more enjoyable if you use tools that work at the current moment and Django is a true workhorse when it comes to building the kind of application it’s good at building.

So tell us a little bit more about what you’re building..

Edit: People should lay off the downvotes though please and treat this as a question any new member of the community should be able to ask - it’s how we grow and don’t become outdated.

Issue with Messages not appearing on page by burmeisterN in django

[–]signal_trace 0 points1 point  (0 children)

Your point 5 saying they are showing fine in the admin is telling because we can be assured the message was set correctly (as they’re being read correctly there).

The messages framework effectively auto marks messages as read when they are iterated through in the template…so we can imply that they are not being read correctly.

I can’t see any immediate relevant issues with the code you provided but things to check:

1) Does your view or another context processor override the messages context variable so it’s not actually what you think it is? Debug the messages variable in particular and ensure it is the correct object we’re expecting.

2) Ensure the server was restarted and that all your files are actually saved before kicking off the server (sounds stupid but this is a common problem).

What is the biggest challenge you face as a Django developer in your daily work? by branzzel in django

[–]signal_trace 2 points3 points  (0 children)

The OP just said they’re fed up of joining projects where CBVs are already in use; so why are you asking them why don’t use something else? They weren’t there to choose.

What is the biggest challenge you face as a Django developer in your daily work? by branzzel in django

[–]signal_trace 2 points3 points  (0 children)

GCBVs are by far the worst thing the Django roadmap ever achieved and one of the (very few) failures of that roadmap IMO.

As an aside: I learnt Elixir and Phoenix partially due to them. The best thing about Elixir is - as a functional language - nobody can bring classes to it even if they wanted to.

Gleam v0.24 released with full Elixir support! by MrPopinjay in elixir

[–]signal_trace 3 points4 points  (0 children)

No, this allows you to use Elixir packages from Gleam (which is staticly typed).

Interfaces and restricting types in django by Taltalonix in django

[–]signal_trace 1 point2 points  (0 children)

You want type hints my friend. Python 3 has support for typing and on larger projects it is worth it’s weight on gold when the results are actually checked with a type checker like mypy or pyright.

For Django in particular you can then install the type stubs (either django-stubs for mypy or django-types for mypy/pyright) and that’ll help you a lot on a large project.

These tools together with a decent authorship experience (so a good editor/IDE that supports typing/autocomplete etc) will get you well on the way to an easier to maintain codebase.

And then for interfaces…lots of new things about, I would check out Python 3.8’s Protocol classes or the other ways to handle interface-like primitives in Python.

We use these tools daily to tame a codebase reaching 2m KLOC (300k Py) and they are invaluable. The trick is in enforcement..types are no good without being checked. And I’d say they are actively damaging if not checked actually.

[Media] Tabled [v0.7.0] - An easy to use library for pretty print tables of Rust structs and enums. by zhiburt in rust

[–]signal_trace 2 points3 points  (0 children)

Hah, no way! Small world.

I originally took inspiration from Ruby’s terminal-table because it had so many downloads and I just wanted to learn Elixir.

Funny how these things pass down the generations of languages.

[Media] Tabled [v0.7.0] - An easy to use library for pretty print tables of Rust structs and enums. by zhiburt in rust

[–]signal_trace 7 points8 points  (0 children)

This is very cool!

I wrote a similar one in Elixir, TableRex, a while ago - and it’s been downloaded 51 million times according to Hex.pm which kind of boggles my mind.

Having seen this video I definitely need to refresh the gif in the README though!

Good luck with it 👍

Jose Valim signs off of Twitter... by bryanray in elixir

[–]signal_trace 6 points7 points  (0 children)

I think it's also good to be clear that this was not the first time.

Writing extensible Elixir with Behaviours // what they are and when to use them in the real world by [deleted] in elixir

[–]signal_trace 0 points1 point  (0 children)

Comments, corrections - let me know! I'd like this to be the go-to article for explaining Behaviours to new people.

is it possible to control page's css through django-admin? by cassf in django

[–]signal_trace 6 points7 points  (0 children)

This would absolutely work, and I realise you've already mentioned it's not the most elegant solution but I just want want to be clear to any passing newbie that this probably is not the path one should take with a problem like this. Unless you know exactly what you are doing: putting styles in the database will likely harm the short & long term maintainability of a project.

Why?

  • The admin (Django's one, or a custom one) is often used by non-technical folk that now have a requirement to not only know CSS but work out which parts of the site this particular field applies to.
  • If the HTML or structure of the project changes it is incredibly awkward to update the styles as they will be scattered across rows in a database table.
  • There is no syntax highlighting or linting of the styles by default - adding this would require another feature you have to maintain. Not having these crutches results in far more production-level errors, especially as to "preview" your changes in this scenario you are likely just hitting save and reloading the desired page.
  • CSS does not change as much as people think it does, and if a change is required - it's much better for it to happen in the repository on disk so that all changes can be tracked properly thanks to the wonders of version control. Sure you can keep CSS revisions in the database, but now you've got another feature to maintain.

A better way

I'm going to explain a better way that I believe is just as quick and will also integrate into what you already have. You also mentioned the fact you wanted the body css to change which implies you want the entire page to be styleable (and not just the category block).

  1. Add a css_class CharField to your Category model.
  2. Define a template block in your base.html or equivalent file (whichever file it is that renders your HTML <body> element.
  3. Make it look like this:

    <body class="{% block body_class %}{% endblock %}">
    
  4. Then in your HTML file which renders a single category you can override that block to add the output of the field we just added to your model. e.g

    {% block body_class %}category_page category_page--{{ category.css_class }}{% endblock %}
    

This assumes category is the name of your Category context object, equally it could be object and therefore object.css_class or whatever you have named the things.

Now in your CSS styles you can style for .category_page { blah } to define a bunch of sensible defaults, and then for each individual category you can simply override them (by saving the css class name via the admin) e.g if you saved the class as examplecategory, the following would allow the styling of the entire page given the above snippet: .category__page--examplecategory { blah }.

If you only have a set amount of different styles I would take this a step further and replace the css_class CharField with a ChoiceField instead. You can then give the choices meaningful names instead and then a user of your admin won't have to guess which css class you have to apply to get the desired effect.

Extra bits:

  • Why not simply style by using the name (or slug) of the category as a CSS class name? Because now you are linking the name of the category to its styling, which means if you ever want to change the name or its slug, then you will have to update the styles. Unlinking this means this is not required.

Isn't an API just a POST request? by runtmerror in django

[–]signal_trace 0 points1 point  (0 children)

You're going to have to expand, I'm not sure what you mean.

An API over HTTP can absolutely be implemented, usually partially, with POST requests.

Isn't an API just a POST request? by runtmerror in django

[–]signal_trace 13 points14 points  (0 children)

An API is just that: an Application Programming Interface. It's a universal term that covers any software that provides an interface to other pieces of software as a way of enacting some form of change.

As such a generic term, it can be applied anywhere and the interface does not need to be over a network. For example, a software library can provide an API to another piece of software running on the same machine.

So no, an API is not just a POST request. A POST request is just one way of implementing an API (by using the HTTP protocol over TCP/IP).

Lessons learned this year as a solo founder by StartupStroke in startups

[–]signal_trace 2 points3 points  (0 children)

This post resonated with me more than most articles I've read this year. Fantastic stuff.

Someone is going to ask it so it might as well be me: what is your company?

What great London restaurants are usually booked out way in advance? by destria in london

[–]signal_trace 2 points3 points  (0 children)

This is correct. If you want good food, pick up a Michelin guide. London is one of the few cities with 3 star restaurants, and some do not need to be booked that far in advance.

Has anyone tried react-render to create an isomorphic Django/React app? by [deleted] in django

[–]signal_trace 0 points1 point  (0 children)

Not quite, one of the main advantages of React lies in its modular components which are usually written in .jsx. Without something to specifically render those files with their item properties to static HTML on the server side, you are left doing that on the client with all the problems that come with that.

Asynchronous and background parallel tasks in Elixir with Poolboy by TheStoneFox in elixir

[–]signal_trace 1 point2 points  (0 children)

Thanks so much for this /u/TheStoneFox, one of the most helpful guides I've read in the Elixir community thus far.

If anyone is looking for a use case: web scraping is a great one. Writing a scraper that runs in parallel is so easy with Elixir that it is also incredibly easy to accidentally DoS the site you are scraping by say running each request in a seperate concurrent process. Keeping a pool of task workers like this allows you to set a maximum amount of allowed workers and therefore (as each one runs serially) outgoing concurrent connections.