|
Label is the name of the field, help text is generally more verbose on how to use the field. Like for a create password field, the label would be 'New Password' and the help text might be '8 characters or more, requires at least one number and special character'
|
# ? Nov 1, 2015 21:06 |
|
|
# ? Jun 5, 2024 07:22 |
https://github.com/defrex/django-after-response/issues/6 I am so confused...why can't pip find version 0.2.2 of this module? PyPi page lists 0.2.2: https://pypi.python.org/pypi/django-after-response
|
|
# ? Nov 2, 2015 20:20 |
|
porksmash posted:Label is the name of the field, help text is generally more verbose on how to use the field. Like for a create password field, the label would be 'New Password' and the help text might be '8 characters or more, requires at least one number and special character'
|
# ? Nov 2, 2015 20:31 |
|
fletcher posted:https://github.com/defrex/django-after-response/issues/6 There's no file associated with the 0.2.2 tag on pypi. If you check the previous version: https://pypi.python.org/pypi/django-after-response/0.2.1 you can see the tar.gz file to download. The current version doesn't have that. I'd reckon the package maintainer screwed up the deploy to pypi somehow?
|
# ? Nov 2, 2015 21:03 |
|
My head, it explodes!Python code:
Python code:
code:
EDIT as per usual, I figured it out literally seconds after I posted... I needed to add this to my script, which I didn't have to when creating models.... code:
Lumpy fucked around with this message at 19:39 on Nov 3, 2015 |
# ? Nov 3, 2015 19:24 |
|
I don't use the django admin too much other than just using the most basic functionality. Today, I was wanting to add the ability to add objects on the reverse side of a ManyToManyField. That's not what this post is about, though...I solved that problem. I was amused to find a django ticket that was submitted 10 years ago, has had continual activity in the meantime, and is as of yet not fixed.
|
# ? Nov 4, 2015 23:55 |
|
Thermopyle posted:I don't use the django admin too much other than just using the most basic functionality. Today, I was wanting to add the ability to add objects on the reverse side of a ManyToManyField. That's not what this post is about, though...I solved that problem. I was amused to find a django ticket that was submitted 10 years ago, has had continual activity in the meantime, and is as of yet not fixed. I found that like 3 months ago (same problem) and also laughed at it.
|
# ? Nov 5, 2015 02:02 |
God dammit. It's those kinds of things that made me want to dig in my heels on modern tools and resist Java.
|
|
# ? Nov 5, 2015 02:44 |
I've got a custom django admin command and I want to capture the log output for when that command is run and make it available for download in a separate file. Think "Console Output" in Jenkins. This command is invoked using django-after-response and I'm running uWSGI. At the beginning of the admin command, I do this: code:
code:
|
|
# ? Nov 24, 2015 10:03 |
|
fletcher posted:I've got a custom django admin command and I want to capture the log output for when that command is run and make it available for download in a separate file. Think "Console Output" in Jenkins. This command is invoked using django-after-response and I'm running uWSGI. I don't know the answer, but it feels like this is a question about the logging module and threading and not Django. And my gut tells me that its too specialized of a question to get much traction in the Python thread and you'll probably have to ask on StackOverflow.
|
# ? Nov 24, 2015 19:20 |
Thermopyle posted:I don't know the answer, but it feels like this is a question about the logging module and threading and not Django. Roger that. Thank you! edit: posted it here http://stackoverflow.com/questions/33905999/to-to-prevent-filehandler-logger-from-impacting-other-threads fletcher fucked around with this message at 00:48 on Nov 25, 2015 |
|
# ? Nov 24, 2015 21:03 |
|
I'm looking for help with forms. It's easy to find instructions on making HTML/js forms, and using Bootstrap etc to make them look nice. I'm having trouble integrating this with Django . I'm using Crispy forms, and am trying to make a search bar with a clickable submit button with a mag-glass icon. Here's the code I'm using to make what I describe, but without the button being clickable; submit works only with enter button:Python code:
Dominoes fucked around with this message at 21:48 on Dec 1, 2015 |
# ? Dec 1, 2015 21:46 |
|
You should use the FieldWithButtons layout object instead: code:
|
# ? Dec 2, 2015 00:31 |
|
Thanks. Do you know if there's a way to make FieldWithButtons work with the icon (seems to only work with text), and placeholder text? The documentation only references it via one example, and with only the button text and name.
|
# ? Dec 2, 2015 10:24 |
|
Oh yeah, crispy renders submit buttons as Inputs by default so you can't use HTML in them. Try replacing the Submit() layout object with this to force it to be an actual button:code:
|
# ? Dec 2, 2015 18:37 |
What's the best-practice way of handling sensitive data strings in server configs (like database passwords) that you don't want to publish to version control? I want to store my secrets a) securely, b) privately, and c) only in a single location, such that both the web server and manage.py can use them. Talking in particular of Apache/wsgi, though I imagine pretty much every server would have similar issues. I thought I was onto something by using a db.cnf file in DATABASES['default']['OPTIONS']['read_default_file'] -- just put the password in that and chown it 600 -- but then Apache can't read it. I had to go back to my previous best solution, which is to store sensitive strings in the Apache configuration itself (chmod 600), and pass them in via wsgi.py hackery: httpd-vhosts.conf code:
code:
But the downside to this is that while it sets the environment variables properly for wsgi, it doesn't help me with manage.py. I can put an export DB_PASS="BlahPassword" into my virtualenv activate script, but that means I'm keeping the pw in two places, which sucks. I thought of parsing the httpd-vhosts.conf in the activate script, but a) it's bash and b) even the python options for parsing Apache config files are either "use some dude's script from 2008" or "do it myself". I've now been through at least three recent jobs at high-flying tech companies where the codebase either doesn't give two shits about storing the passwords directly in settings.py, or else they apparently run totally password-less and just rely on firewall rules for security or something. This can't really be the state of things in tyool 2015, can it? Data Graham fucked around with this message at 16:46 on Dec 7, 2015 |
|
# ? Dec 7, 2015 16:43 |
|
I'm curious too. I've been making a file called private.py that I put on gitignore. I use an if/else statement based on a server environment var in settings.py to prevent an import error when deployed. It seems like an awkward solution.
|
# ? Dec 7, 2015 19:52 |
|
You can just make a separate file with your sensitive stuff and import * it in settings.py. Don't commit that file to your repo and you're good.
|
# ? Dec 7, 2015 19:56 |
|
I think I'm just missing something here, because my question is...why does your web server need to know your database connection information? I mean, I usually just set the enviornment variables on the server and read them in my django settings and that works...
|
# ? Dec 7, 2015 20:34 |
porksmash posted:You can just make a separate file with your sensitive stuff and import * it in settings.py. Don't commit that file to your repo and you're good. Unfortunately that doesn't work if it's owned by root and chmod 600. I can chown it www or chmod it 644 so Apache can see it, but then it's also visible to any other programs on the server that want to try to read it. I suppose one answer to this is "don't run a server with ~users and critical data at the same time", and maybe that's a fair stance to take nowadays, but I feel like that can't actually be the only right answer in the world of unix permissions.
|
|
# ? Dec 7, 2015 20:38 |
Thermopyle posted:I think I'm just missing something here, because my question is...why does your web server need to know your database connection information? Where do you set them? E: It's not that the web server needs to see the info per se, it's that wsgi is being executed as www, and it needs that info to connect. It has to come from somewhere that's either accessible to www or passed down to it from the web server itself (which is launched by root), and the former seems like a non-starter, so I'm back to the latter. Data Graham fucked around with this message at 20:43 on Dec 7, 2015 |
|
# ? Dec 7, 2015 20:39 |
|
Oh, I wasn't thinking about that...it's been a long time since I deployed to something that wasn't something like Heroku or whatever which all have their own way of setting env variables. I seem to recall Django recommending setting them in wsgi.py
|
# ? Dec 7, 2015 21:24 |
|
Connecting to a Heroku database locally. Or storing API keys.
|
# ? Dec 7, 2015 21:37 |
|
Data Graham posted:Unfortunately that doesn't work if it's owned by root and chmod 600. I haven't dealt with Apache in a while, so this may be a big steaming pile of nonsense... We run uwsgi under it's own user, not www or root and the web server proxies to it. Only that uwsgi user can read it's own files. The web server doesn't have to be able to read it and it certainly doesn't have to be world readable. I like this approach because you can do more (usually in dev) than just credentials without a ton of logic in your settings. Want to enable some middleware for profiling? Drastically change logging config? Turn on debug_toolbar? It's just a python file, have a ball.
|
# ? Dec 7, 2015 22:50 |
|
Yeah, I was thinking about this last night and trying to remember how I handled this last time I was dealing with Django on something other than heroku or similar, and I'm pretty sure it was something like this:Gounads posted:I haven't dealt with Apache in a while, so this may be a big steaming pile of nonsense...
|
# ? Dec 8, 2015 16:12 |
Not bad. Proxying sounds pretty solid. It might be overkill for the kinds of things I'm doing right now, but I'll bear it in mind for the next time I get into it. Thanks!
|
|
# ? Dec 8, 2015 17:37 |
I stumbled into an interesting inconsistency in our unit tests. We're using Nose and sometimes we have factories.MyButtFactory(name='fart') and other times it's factories.MyButtFactory.create(name='toot'). It looks like .create is the only one that supports overriding from the docs, but I find it hard to believe we have as many tests as we do which are functional if this isn't the case. What is the correct or standard way of doing it? .create? What if there are no args? .create()?
|
|
# ? Dec 8, 2015 19:40 |
|
Why does LocationSerializer keep telling me that I'm passing a null value for company_id?Python code:
quote:django.db.utils.IntegrityError: null value in column "company_id" violates not-null constraint I know the co object has an id because I see a number in the print() after co.save() so I'm not sure why the proceeding serializer isn't recognizing it when I try to create a Location object. I've even tried changing 'company' to 'company_id' but that didn't help. Besides, I'm pretty sure when I feed in data to the serializer via an API call I pass in a 'company' key in the JSON, so it should work the same way here, right?
|
# ? Dec 11, 2015 20:18 |
Karthe posted:Why does LocationSerializer keep telling me that I'm passing a null value for company_id? I believe I've encountered this fuckery before. I'm guessing you're using the Django Rest Framework. Check to make sure the third column of your database table is actually company_id. If it's actually the *stations* attribute that has not null, perhaps the [] is being cast to null?
|
|
# ? Dec 11, 2015 20:35 |
|
Jo posted:I believe I've encountered this fuckery before. I'm guessing you're using the Django Rest Framework. Check to make sure the third column of your database table is actually company_id. If it's actually the *stations* attribute that has not null, perhaps the [] is being cast to null? Python code:
Python code:
Python code:
|
# ? Dec 11, 2015 20:54 |
|
If I'm using a cached_db session store, what's a reasonable amount of data to store in a user's session? Am I just limited by RAM? I'm trying to figure out how to store up to maybe 2000 model instances that were parsed out of an uploaded file. I want the changes to be approved by the user before saving all of them, so the process will be something like: request: Upload file response: parsed file and present results request: Apply or don't apply response: models updated or changes discarded. The problem I'm trying to work around is that the upload may contain a mix of new instances and updated instances, so simply saving all the imported data with a 'not yet approved' flag set won't quite work. I don't want new PKs for the updated instances. I think storing the model instances in the session for one page load would be acceptable, but I just wanted to see if I was missing another more obvious method.
|
# ? Jan 12, 2016 00:05 |
|
Do any of you know if there is a way to change the order than django does a clean() on form data? Essentially I have a form in the order I want and it validates email to come from a certain domain. I would like it to skip that validation if the user is from outside as a guest but the 'position' field is must lower in the form. When I do position = self.cleaned_data.get('position') it stores None to position. I have tested tossing position ahead of the email field and everything processes through just fine. If there is a way to clean() position earlier somehow it would be super helpful.
|
# ? Jan 13, 2016 00:44 |
* Foo has something happen in our application. * Foo's triggers on the database side run, changing a property of foo to, say, "butts". * Foo is saved, but the cached value of the attributes is used and "butts" is overwritten by old data. Is there a way to suppress the writing of the specified property? Can I declare it ephemeral/volatile? We can't use Django's DB triggers/hooks/signals because there's no guarantee we're going to be the ones to touch the database. EDIT: Disregard, there was another trigger which didn't get removed that was causing the data to be overwritten. Jo fucked around with this message at 02:48 on Jan 22, 2016 |
|
# ? Jan 22, 2016 00:50 |
I don't know if I fully understand the issue, but it sounds like you might be looking for something like update_fields?
|
|
# ? Jan 22, 2016 01:19 |
I'm back with another bug, this time with Django Celery. I have five tasks, A, B, C, D, and E. All of them are supposed to run every ten minutes or so. B, C, D, and E run just fine. A, however, is running three times. It's supposed to run every ten minutes, but I'm seeing three copies of "Received task: A [2678195-1543983-112-abafd]" every ten minutes instead of one. They all fire within a few seconds of each other. Here's what I've tried:
I also tried injecting a stack trace to see if it was possibly another method invoking A. Nope. Same stack trace. FINALLY, after removing the task from celeryconfig, I noticed it was still being called twice. This says to me that there are other things on the machine running tasks. When I do a `ps aux | grep celery` I only see my tasks. Any way I can track down who is adding the task to celery? Jo fucked around with this message at 19:36 on Jan 26, 2016 |
|
# ? Jan 26, 2016 19:29 |
Has anyone successfully gotten django-two-factor-auth working with the Django admin? I've followed the setup instructions in the docs, particularly this part: http://django-two-factor-auth.readthedocs.org/en/stable/implementing.html#admin-site And I've got this in my urls.py: code:
Seems like the models aren't getting registered? Any ideas on how to even debug this?
|
|
# ? Jan 27, 2016 02:21 |
Never mind the above, incidentally. Some more loving around and code:
(Note that AdminSiteOTPRequired already exists in two_factor.admin anyway so I could have imported it from there; but I also wanted to use an existing AdminSite subclass to allow django.contrib.gis.admin.GeoModelAdmin) Just a documentation thing if anything. Data Graham fucked around with this message at 23:26 on Jan 27, 2016 |
|
# ? Jan 27, 2016 23:24 |
|
Anybody in here tried to set up and use any of the various solutions out there for Websockets + Django? How'd it go? It seems like everything is kinda hacky and a lot of effort so I haven't actually tried anything yet... I'm actually leaning towards just writing something completely separate from my Django project that interacts with its already existing REST API, and serves it out out over its own websocket implementation.
|
# ? Feb 15, 2016 17:38 |
|
Thermopyle posted:I'm actually leaning towards just writing something completely separate from my Django project that interacts with its already existing REST API, and serves it out out over its own websocket implementation. This is what I did, it works a lot better than trying to integrate websockets into django, in my limited experience wrestling with things like swampdragon.
|
# ? Feb 15, 2016 17:59 |
|
|
# ? Jun 5, 2024 07:22 |
|
Okay, because I'm an idiot, I need help grasping something apparently so basic it's embarrassing. I have some code that will run a "long running process" that, if it succeeds, I'd like to create a bunch of Model objects with the results. If it does not succeed (returns no results) I need the user to know that. Obviously, Celery is the thing to use to run the long-running code, and I'd make a task for that:Python code:
Python code:
How do I get the ID of task after the fact? For example, if a user wants to check on the status of queries they are running. Do I need to create a new UserTasks model and store the id of task in there? How do I *get* the ID of task to store it? Will the result of the task be the True / False I return from it? In a view that looks up a task status, how do I do that? I see that django-celery has a couple views that will do this for me, which is neat, but what if I want to look at this stuff in my own view? Sorry for being a dumb-dumb.
|
# ? Feb 25, 2016 18:07 |