|
Thermopyle posted:Snake case because most of your coding should be done on the backend, not the front.
|
# ¿ Sep 14, 2018 20:23 |
|
|
# ¿ May 16, 2024 21:24 |
|
Business posted:I'm just learning and going through tutorials and I have a dumb question. When people work on a project in django, are they generally just VIMing or whatever around to the different things they need to edit each time they add something? I hope it's just a learning curve thing but I'm finding it hard to keep a 'map' of every file that needs to be edited each time I add a new page or template or whatever. Relatedly, is there a good way to keep track of your db models other than just keeping them in a text file?
|
# ¿ Feb 11, 2019 06:08 |
|
I love the new model enums; it's something I've wanted for a while. Gives you different varieties based on how you want it to be stored in the db, ie integer, char, or something else, then works like a normal enum in the Python code. Migrating's easy, assuming you don't change how the data's represented in the DB. Ie replace this: Python code:
Python code:
Dominoes fucked around with this message at 03:59 on Dec 3, 2019 |
# ¿ Dec 3, 2019 03:48 |
|
The only thing that broke for me was having to replace { % load staticfiles %} with { % load static %}. Check out the list of removed features. I finally was able to remove this comment from my models.py: # Choices listed here; Django should just support enums directly...
|
# ¿ Dec 3, 2019 03:56 |
|
epalm posted:Can we talk about Class Based Views for a sec?
|
# ¿ Dec 3, 2019 18:30 |
|
Much appreciated. I think I need to read one of those tutorials and see where it would make the code cleaner. Does anyone know how to handle CSRF tokens for forms? If I'm making a normal fetch request, I can pass the token as a header, after retrieving from document.cookie and doing some processing. For using the <form /> approach, which I've been using for file downloads (There may be a way to download files with Fetch, but I'm struggling on that too), I've been using a React component, where you just insert this tag somewhere in your form: <DjangoCSRFToken />. How can I do form based approaches without the React module? I'm doing a non-react project, and want to download a file, but am struggling. Edit: I think I solved it, by passing an input with type="hidden", name="csrfmiddlewaretoken", and value, the result of the document.cookie used in the first approach. Gleaned from the Github of that React helper page. Dominoes fucked around with this message at 21:07 on Dec 3, 2019 |
# ¿ Dec 3, 2019 20:48 |
|
Hey - I'm having a struggle with preventing people from making superusers from the default Admin User page. About 80% of the time my custom form without the superuser tick works, but sometimes the original form works, and lets staff members make someone a useruser. (eg from mashing F5, or getting lucky) Relevant code:Python code:
Is there a more "hard" way to prevent people from creating superusers at a deeper level than hiding fields? Using the latest Django. Thank you.
|
# ¿ Sep 18, 2021 16:03 |
|
Thank you. That worked!
|
# ¿ Sep 21, 2021 10:39 |
|
Data Graham posted:Someone please tell me if there's a better way to do this. Python code:
|
# ¿ Mar 19, 2022 02:05 |
|
|
# ¿ May 16, 2024 21:24 |
|
death cob for cutie posted:I'm helping to take over Votefinder, a Django project for keeping track of voting in games of Mafia on the forums.
|
# ¿ Apr 1, 2023 01:58 |