|
Worth mentioning that if you're using virtualenv (which is very good idea) to develop Django apps, you specify the Python version with a flag when you create the env.
|
# ? Jan 2, 2019 19:30 |
|
|
# ? Jun 6, 2024 05:59 |
|
minato posted:Worth mentioning that if you're using virtualenv (which is very good idea) to develop Django apps, you specify the Python version with a flag when you create the env. I'd say that goes beyond "very good idea" to "essentially malpractice to not do."
|
# ? Jan 3, 2019 00:24 |
|
NtotheTC posted:Is there a go-to e-commerce library for django that you guys use? Theres any number of them on django packages and django-oscar appears to be winning but popularity does not always trump experience I really enjoyed cartridge when I was building those. I thought it was easy to implement, customize, and extend. Haven’t used it since 2015 but might be worth a look.
|
# ? Jan 5, 2019 06:40 |
|
What are you guys using for error logging these days? I liked Sentry but they seem very reticent to move off of python2.7 and django 1.6 and i cant decide if i should use it in a commercial setting because of that
|
# ? Jan 31, 2019 13:00 |
|
I've used papertrail, loggly, and my own ELK stack. All work fine. I actually came in here to post something that I stumble across like once a year and then next time I want to find it I can't. I give you a complete Django project: code:
|
# ? Jan 31, 2019 18:03 |
|
I keep reading horror stories about those dev contractor sites. Where would be a reasonable place to look for a django dev to convert an old site from Python 2 and Django 1.11 using function-based views to Python 3 and Django 2.2 using class-based views? I'd like to jump from one LTS version to the next, and 2.2 has been pre-released (aiming to be fully released this April). It's a 24 page internal site, mostly just a LOB app with lists of records users can open, view, and edit. I know exactly what I want, and is something I could do myself, but right now I have more money than time.
|
# ? Feb 1, 2019 23:18 |
epalm posted:I keep reading horror stories about those dev contractor sites. Where would be a reasonable place to look for a django dev to convert an old site from Python 2 and Django 1.11 using function-based views to Python 3 and Django 2.2 using class-based views? I'd like to jump from one LTS version to the next, and 2.2 has been pre-released (aiming to be fully released this April). It's a 24 page internal site, mostly just a LOB app with lists of records users can open, view, and edit. It's intern season! Hire yourself an intern from a decent school and have them bang it out over the summer under your supervision.
|
|
# ? Feb 1, 2019 23:42 |
|
epalm posted:I know exactly what I want, and is something I could do myself, but right now I have more money than time. I have time and want money if you're open to a little contract, but I don't do gig sites like Upwork. Email me sa@porksmash.com if you want to discuss and I can send you some stuff I've made.
|
# ? Feb 2, 2019 05:33 |
|
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? I feel like I get how the pieces fit together over the course of a tutorial or whatever and debugging hasn't been bad but I'm having a hell of a time keeping up with all the moving parts even in a small project
|
# ? Feb 10, 2019 20:44 |
|
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? Where things go make sense if you understand how Django and web frameworks in general work. The web server (nginx or apache) hands a web request to Django. Django looks in urls.py to see which view function or class to hand the request to. The view takes the template you specify and adds the data the template requires. The view returns the rendered template, and Django passes it back to the web server. Once you understand that it's never really a question of where you should add or edit stuff.
|
# ? Feb 10, 2019 22:14 |
|
I use an IDE for Django, maybe an Emacs or VIM expert could keep up but honestly I'd be lost without it. The gold standard is pycharm which has a free (community) version and a paid (professional) version. The community version unfortunately doesn't come with all the cool Django integration stuff but still allows you to see the project structure and bounce around the code so is going to be lightyears ahead of VIM. I haven't used it personally so I can't vouch for it but possibly VScode as a free alternative? It's not going to come close to the paid version of pycharm but for hobby coding might be the easier choice.
|
# ? Feb 10, 2019 22:18 |
|
VS Code works fine and is what I use, it's even possible to setup pylint with Django within it.
|
# ? Feb 11, 2019 01:06 |
|
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 |
|
VIM with bufferTabs.
|
# ? Feb 12, 2019 04:43 |
|
I can't seem to find this answer anywhere for some reason, and it seems like a really simple question: In Django REST Framework, when using many=True in your serializer to support creation of multiple objects per request....is there a limit to the number of objects in a single request? Also is there a default rate limit for requests to an endpoint? I don't know why none of this appears to be in their docs, their bit about multiple objects is just "build a serializer, user many=true" and that's about it.
|
# ? Feb 14, 2019 16:58 |
|
BaronVonVaderham posted:I can't seem to find this answer anywhere for some reason, and it seems like a really simple question: many=True actually uses ListSerializer. ListSerializer just calls `create` for each item in the list, so the only limits you're going to run into is how long you want a request to take or how long before your web server shuts down the request.
|
# ? Feb 14, 2019 17:08 |
|
Thermopyle posted:many=True actually uses ListSerializer. Thanks. We're doing some wonky extension of the serializer I guess (not my endpoint, I was asked to build this, then went digging and found it already exists), but cool, I'll just have to do some testing to see where that break point happens and then round that down or something to be safe. The guy on our CRM team asking about this, who requested the endpoint, seems to want to abuse this thing, so I probably need to really underestimate those limits.
|
# ? Feb 14, 2019 17:47 |
|
Doesn’t look like I can use check as a field name, if it’s a foreign key. I get a SystemCheckError. However, the docs list only two restrictions on field names: A field name cannot be a Python reserved word, and cannot contain more than one underscore in a row. https://stackoverflow.com/questions/54681167/django-model-field-name-check-raises-systemcheckerror Are the docs wrong, or am I doing something wrong? epswing fucked around with this message at 22:49 on Feb 14, 2019 |
# ? Feb 14, 2019 20:13 |
|
I wanna start baby’s first Django project this week, basically displaying a subset of a pandas dataframe in a bootstrap table based on url strings. I picked out a bootstrap theme I like. I watched sentdex’s Django tutorials and it seems pretty doable. Copy paste some static stuff, add some jinja things, seems easy enough. What are packages like this for? Would it make getting started easier? https://pypi.org/project/django-bootstrap4/ My current website is with weebly and I’m thinking about redoing it. It’d be nice if my nontechnical cofounder can make minor edits with a WYSIWYG editor. Should I got for djangoCMS? Is this useful: https://github.com/divio/djangocms-bootstrap4
|
# ? May 28, 2019 02:00 |
|
CarForumPoster posted:I watched sentdex’s Django tutorials and it seems pretty doable. Copy paste some static stuff, add some jinja things, seems easy enough. I wouldn't use jinja. Not because jinja is bad, but because Django already has its own template language that is as good or better. CarForumPoster posted:What are packages like this for? Would it make getting started easier? I think it basically just adds some template tags that insert all the bootstrap boilerplate for you. Whether its useful kinda depends on how familiar you are with Bootstrap. I find that if you're not familiar with BS, the extra level of abstraction that packages like this add can cause more confusion than they prevent. On the other hand if you're familiar with BS, they can save you some typing I guess. CarForumPoster posted:Should I got for djangoCMS? It really just depends on how complicated your CMS needs are. I think maybe I'd try building what you need with django itself first.
|
# ? May 28, 2019 20:02 |
|
I have a Car which has a custom reserve_car permission which is checked by a DRF view when a user tries to reserve a Car. Here's a test which checks the permission works. The test passes and everything works fine. Python code:
Does this mean if a user of my api is given a new permission (or has a permission taken away), it won't take affect until they request a new api token? Is the server caching user permissions? Or just the test framework is caching user permissions? epswing fucked around with this message at 14:50 on May 30, 2019 |
# ? May 29, 2019 02:39 |
I'm having problems with session cookies disappearing after an HttpResponseRedirect. I'm overriding the built-in password recovery views, which do this when you click on the emailed token link (django.contrib.auth.views.PasswordResetConfirmView): code:
However, in my setup, after it sets the token in the session cookie and issues the redirect, the resulting /set-password/ page has NO session cookies. No cookies at all, in fact. So they get the "yo you followed a bogus link" page. If I copy the same URL into a new browser window, it DOES have the session cookie, and it renders the reset form properly. So it's setting the session value properly. But the cookie is being lost during the 302 redirect somehow. I've tried fiddling with SESSION_COOKIE_DOMAIN and SESSION_COOKIE_SECURE (this is a production server with a valid SSL cert, and all the URLs are using [url]https://[/url] with the same hostname), to no avail. I'm not finding anything addressing this in the usual places. Django 2.1.7, Python 3.6. Anyone dealt with this? I feel like it must be familiar ground for some of us. E: I should note that this worked perfectly fine in Django 1.11 and earlier. I just recently upgraded to Dj2 and Py3, and this apparently stopped working right then. Data Graham fucked around with this message at 02:40 on Jun 1, 2019 |
|
# ? Jun 1, 2019 02:10 |
|
Data Graham posted:I'm having problems with session cookies disappearing after an HttpResponseRedirect. What's the cookie path? Unless a path is specified, a cookie is only going to match the document where you set the cookie.
|
# ? Jun 1, 2019 02:42 |
The path is / (default). Anyway what the fuuuuuuck. Further blind poking has revealed that this behavior ONLY happens when I'm following the email link by clicking on it IN iCloud mail IN Safari. In other words if I paste the un-redirected URL (with the live token) straight into the browser, the cookie gets set fine and persists through the redirect, and I get the reset form. The problem doesn't happen if I make a raw HTML page with the link in it on my local box and open it locally in Safari, nor if I put that page on a webserver and open it remotely in Safari. It doesn't happen if I click an activated link in any non-web application (like Notes). It doesn't happen in iCloud mail in Chrome. Apparently iCloud Mail is doing some kind of goofy javascript witchery on its activated links ...? Ugh.
|
|
# ? Jun 1, 2019 03:18 |
|
Is there a pattern for defining a ModelAdmin to handle the shared fields for Models that share an abstract base and then also the stuff specific to the child Models? My first guess is define a ModelAdmin that handles the common stuff and subclass it for each child model with the specific stuff and register the child ModelAdmins to the child Models but idk how far you can take that -- at first glance it probably works for say setting some shared readonly_fields but I'm not sure about more complicated layout and stuff?
|
# ? Jun 13, 2019 03:45 |
|
Has anyone been deploying on AWS lambda? Seems cool but I’m a little unclear if best practice is still to mess with Cookiecutter templates then install Zappa or just go with the default
|
# ? Jul 3, 2019 04:42 |
|
I've got a noob question. I see people online often recommending using React + Django or Vue + Django for a development stack... are these people pretty much exclusively referring to using DRF to create an API that your front end talks to? Or is there some other approach I'm not aware of?
|
# ? Jul 5, 2019 16:23 |
|
There are halfway-house integration libraries out there that convert django widgets into react components automagically but they're almost always more trouble than they're worth in the long run. My personal approach is API and a separate frontend
|
# ? Jul 5, 2019 16:31 |
|
punished milkman posted:are these people pretty much exclusively referring to using DRF to create an API that your front end talks to? Yeah.
|
# ? Jul 6, 2019 00:08 |
|
Here's a pretty standard setup for a nested writeable serializer, which allows the client to GET a user, and PUT it back with a different set of groups:Python code:
pre:{ "id": 1, "username": "user" "groups": [ { "id": 1, "name": "G1" }, { "id": 2, "name": "G2" } ], } But what I'd like to do, because the group model is small/simple with a unique name field, is be able to GET a user like this: pre:{ "id": 1, "username": "user" "groups": ["G1", "G2"], } pre:{ "id": 1, "username": "user" "groups": ["G1", "G3", "G4"], } epswing fucked around with this message at 03:22 on Jul 6, 2019 |
# ? Jul 6, 2019 03:19 |
|
Not sure if this is the right answer, but what I did was add a group_names property to User:Python code:
Python code:
Python code:
Seems to work, didn't need ListSerializer in the end.
|
# ? Jul 6, 2019 14:09 |
|
I think it was in this thread that someone had an issue with their site loading already "pre scrolled down" or in the middle of the page. I'm having the same issue, does this ring a bell to anyone?
|
# ? Jul 29, 2019 11:55 |
|
What are people's opinions on using UUIDs everywhere as the primary key? I'm starting a new Django project and while the framework has made it easy for a long time, I've seen mixed ideas on the Internet: that using UUIDs is both terrible and fine. For now I'm giving models that are going to be on my REST interface (which is most of them) an additional field that is based on the ShortUUID from Django extensions. Still, carting both around and dorking around with Django-REST-Framework to use both PKs and UUIDs seems a little silly.
|
# ? Aug 10, 2019 17:26 |
I just changed the one-and-only model in my latest project whose pk's are user-facing to UUIDs. That is the main reason I would do it — it avoids exposing integer IDs as an attack facet (so some wiseguy doesn't just go "hey my ID is 1142, I wonder if I can make this same API call to 1141 and see if I get someone else's stuff"). I wouldn't use a UUID in addition to a pk though. Just make your UUIDField (or ShortUUIDField) your pk and be done with it.
|
|
# ? Aug 10, 2019 19:17 |
|
I always liked this article about readable URLs too: https://wellfire.co/learn/fast-and-beautiful-urls-with-django/ only applies if you care what the user sees in the url bar though
|
# ? Aug 10, 2019 19:27 |
|
I use UUID primary keys often and like it, especially if it's user facing so they can't guess neighboring rows. It makes no sense to me to have a regular integer PK AND a UUID in a different indexed column, especially if the UUID will be the primary lookup column. From my research postgresql suffers no performance impacts other than the fact that a uuid requires more storage than an int/bigint. I have not noticed any issues including tables with 10mil+ rows. Dunno anything about other DB engines though.
|
# ? Aug 10, 2019 19:36 |
Aside though, thanks for the tip on ShortUUIDField (and django-extensions). I like having a uuid that isn't so obviously one. I was just on the verge of writing my own to do basically the same thing but Data Graham fucked around with this message at 22:17 on Aug 10, 2019 |
|
# ? Aug 10, 2019 21:22 |
|
I use https://hashids.org to mitigate the “modify the url to find other records” problem.
|
# ? Aug 10, 2019 23:23 |
|
I mean, you guys use permissions all the time anyway right so URL modding isn't an issue?
|
# ? Aug 10, 2019 23:34 |
|
|
# ? Jun 6, 2024 05:59 |
There’s other kinds of opsec than making sure user=request.user but yeah
|
|
# ? Aug 10, 2019 23:49 |