|
KingNastidon posted:I'm working on a django app that uses pandas and embedded bokeh plots for portfolio analysis with time series data. I'm looking to move the app to a shared hosting service like webfaction or dreamhost to demo to my bosses and argue my time should be spent on this versus things that actually generate revenue for the company. Hi, I'm the Bokeh project lead. The bokeh-server is definitely intended for people to be able to run, either on their own local on-premise assets, or in some hosted/cloud situation. There's several ways to run it: It has a Flask Blueprint, so if you are using Flask you can incorporate it directly into an existing Flask server. Otherwise, it can be run as a command-line tool (config options supplied on the command line as well) or, you can import the server and run it from python code. I don't know about the particulars of your deployment, but you would probably just want to start it using whatever startup script controls your deployment, then your django app can interact with it either by templating documents that load plots, etc. from the bokeh-server, or but storing plots and data on the server using the plotting APIs.
|
# ? Sep 12, 2014 15:13 |
|
|
# ? Jun 1, 2024 05:18 |
|
I may be misunderstanding your question but is this what you want?code:
|
# ? Sep 13, 2014 00:59 |
|
I want to be able to allow any surface, if paved_only is False.
|
# ? Sep 13, 2014 04:44 |
|
So...code:
|
# ? Sep 15, 2014 18:33 |
|
surface might have a value. Repeating the filter statement for each if/or doesn't make sense if there are multiple filter fields; ie the solution I posted, while convoluted, is cleaner. I'm looking for something like query_parameter=anything
|
# ? Sep 15, 2014 18:51 |
|
Are there any tools people can recommend for importing data when you don't have control of the source? I have a bunch of excel documents (and models I've written for them)- I can read the data from the documents just fine but it seems like writing the import code will be a huge unmaintainable mess since I'm basically duplicating my models code but in a different place.
|
# ? Sep 15, 2014 19:58 |
king salmon posted:Are there any tools people can recommend for importing data when you don't have control of the source? I have a bunch of excel documents (and models I've written for them)- I can read the data from the documents just fine but it seems like writing the import code will be a huge unmaintainable mess since I'm basically duplicating my models code but in a different place. I made a couple custom management commands for importing data into my app. No need to duplicate your models in that case, since you can access everything in your project from the management command.
|
|
# ? Sep 15, 2014 20:21 |
|
As a first project, I'm turning a small personal script into something with a web interface using Django, and I can't for the life of me get configparser to work, even with just running locally. I get a NameError (which basically means configparser is trying and failing to assign value from the .ini file) every time. Doesn't matter if I make it just creds.ini or /backend/creds.ini or /screlp/backend/creds.ini. I've got the four values hardcoded for now, but it's obviously not wise to git those. Also hello there little docstring incongruity, I see you!
|
# ? Sep 27, 2014 14:08 |
|
Literally Elvis posted:As a first project, I'm turning a small personal script into something with a web interface using Django, and I can't for the life of me get configparser to work, even with just running locally. You should generally define a DJANGO_ROOT variable in your settings that's the root path of the whole project. Your config.read() should call os.path.join(DJANGO_ROOT, etc., etc., etc., etc.) to point to the creds file. Alternatively (and probably as a better practice), credentials should be defined as environment variables and read in using os.environ. Generally keys, credentials, and sensitive information like passwords should be defined as environment variables so as to keep them out of source.
|
# ? Sep 27, 2014 14:18 |
|
With the OP being 6 years old at this point, is there a recommend book for learning the basics of Django? A Django for non-programmers book? I've been teaching myself Python to help out at work and I've interested in learning and creating a web app.
Hughmoris fucked around with this message at 01:36 on Oct 5, 2014 |
# ? Oct 5, 2014 01:15 |
|
Hughmoris posted:With the OP being 6 years old at this point, is there a recommend book for learning the basics of Django? A Django for non-programmers book? I've been teaching myself Python to help out at work and I've interested in learning and creating a web app. I think most of the django books are kinda old at this point. Django updates semi-frequently. Have you done the official tutorial? If not, maybe try that and ask questions about it here. The book that has been talked about the most in this thread recently is Two Scoops of Django, but that's less for teaching beginners, and more for laying out best practices for people already using Django. Now, that's not to say you shouldn't read it. You should definitely read it.
|
# ? Oct 5, 2014 02:45 |
|
Thermopyle posted:I think most of the django books are kinda old at this point. Django updates semi-frequently. Thanks. I tried walking through the official tutorial but I was quickly overwhelmed. Its clear I need to put more time in learning objects and classes.
|
# ? Oct 5, 2014 03:27 |
|
FWIW, I'll be doing a Django beginner series at Treehouse in a few months, probably early 2015.
|
# ? Oct 6, 2014 17:49 |
|
Using database-backed sessions, is PickleSerializer always a bad idea? The docs say to not use it with cookie-based session data but I've seen calls elsewhere to just not ever use it at all. I'm updating an old app originally written in 1.3 which stores a lot of datatypes the JSONSerializer doesn't seem to like (decimals, dates). I probably should rewrite the whole thing anyway but I was hoping to avoid that right now.
|
# ? Oct 10, 2014 14:35 |
|
Does anyone serve angularjs (or any other kind of 1-page html/js) apps through django or have good ideas how to do it? I'm trying to think of a neat way to achieve it and keep running into knotty problems. It seems like you want to have a django app for your angularjs app, that has AppView/API URLs, and a templates folder with an index.html that somehow includes your angularjs app .html, but getting this to work with my versioned, cache-buster js/css produced by grunt tasks etc seems like a challenge.
|
# ? Oct 10, 2014 20:41 |
|
ozmunkeh posted:I'm updating an old app originally written in 1.3 which stores a lot of datatypes the JSONSerializer doesn't seem to like (decimals, dates). And yes, if you value your sanity, just don't use the pickle one at all.
|
# ? Oct 11, 2014 11:58 |
|
Yay posted:And yes, if you value your sanity, just don't use the pickle one at all. That's a bit ominous. Care to share why not?
|
# ? Oct 11, 2014 14:50 |
|
NtotheTC posted:Does anyone serve angularjs (or any other kind of 1-page html/js) apps through django or have good ideas how to do it? I'm trying to think of a neat way to achieve it and keep running into knotty problems. It seems like you want to have a django app for your angularjs app, that has AppView/API URLs, and a templates folder with an index.html that somehow includes your angularjs app .html, but getting this to work with my versioned, cache-buster js/css produced by grunt tasks etc seems like a challenge. I put my angular stuff in staticfiles, and then end up serving them off of a CDN. The only angular in a django template is the reference to the script and a root node tagged with ng-app (and usually a directive that loads a template). I usually also make an API app that the angular client talks to.
|
# ? Oct 24, 2014 14:24 |
|
Yeah, that's all logical stuff thanks. I think i really need to move away from serving apps via django to be honest. Its just not very robust. As an aside: How do people here like to setup their dev environment at home? I'm disliking my current situation which is a dual boot of Ubuntu on my windows machine, its a hassle to power down/boot up a different os if I want to do something else. I've heard people talk of using virtual machines, which sounds fine but is there any way to run them so that they "feel" native while you're using them? As in span across multiple monitors seamlessly and just have a key combo or something to switch back to windows. Failing that I guess I buy a dev laptop and just plug it in when needed, portable solution but expensive
|
# ? Oct 28, 2014 11:41 |
|
How about using Vagrant? You develop as normal on your windows box, but the code runs in the vm.
|
# ? Oct 28, 2014 11:48 |
|
Id want to do my development in a Linux environment, I just couldn't get used to using windows to develop again. The issue is I do like vagrant and the ability to build/teardown a server that runs the code that has the exact same config as the production box. But then I'm running vagrant in a Linux vm and things get complicated possibly.
|
# ? Oct 28, 2014 12:23 |
|
NtotheTC posted:Yeah, that's all logical stuff thanks. I think i really need to move away from serving apps via django to be honest. Its just not very robust. I run Windows and dev in a virtual machine running Ubuntu. The virtual machine occupies two of my three monitors. If I covered the third monitor, you'd never know it was a VM.
|
# ? Oct 28, 2014 17:16 |
NtotheTC posted:Id want to do my development in a Linux environment, I just couldn't get used to using windows to develop again. The issue is I do like vagrant and the ability to build/teardown a server that runs the code that has the exact same config as the production box. But then I'm running vagrant in a Linux vm and things get complicated possibly. Instead of spinning up local VMs with Vagrant you could spin up EC2 VMs with Vagrant
|
|
# ? Oct 28, 2014 18:32 |
|
Thermopyle posted:I run Windows and dev in a virtual machine running Ubuntu. The virtual machine occupies two of my three monitors. Do you use Vagrant or similar to handle the dev environment or is it run locally? I'm not completely against the idea of just using django's runserver to run the code locally on a dev VM, but I do like "safety net" of running my code in the same environment as my production. fletcher posted:Instead of spinning up local VMs with Vagrant you could spin up EC2 VMs with Vagrant This is very interesting, I wasn't aware you could do this. I'm having trouble deciphering AWS's pricing structure though- it seems to be a case of "Don't worry we'll just take the money if you do anything expensive" but I'd like to know roughly how much I'd be spending or whether I could just mooch around in the free-tier. I guess I'd be averaging no more than 80 hours of dev time a month + some cloud storage of VM images/backups etc.
|
# ? Oct 28, 2014 19:55 |
|
NtotheTC posted:Do you use Vagrant or similar to handle the dev environment or is it run locally? I'm not completely against the idea of just using django's runserver to run the code locally on a dev VM, but I do like "safety net" of running my code in the same environment as my production. Nah, it's just run locally.
|
# ? Oct 28, 2014 19:57 |
NtotheTC posted:Do you use Vagrant or similar to handle the dev environment or is it run locally? I'm not completely against the idea of just using django's runserver to run the code locally on a dev VM, but I do like "safety net" of running my code in the same environment as my production. I use both Django's runserver during development but then I use a Vagrant VM (provisioned with Chef) for testing before I push it to production. Try the free tier first, if you outgrow it, it's really inexpensive to run an EC2 VM for only 80 hours a month. The storage and all that is super cheap, just calculate your monthly cost on the instance price per hour * number of hours per month.
|
|
# ? Oct 28, 2014 21:21 |
I want to store a latitude & longitude in a Django model and display the points on a Google Maps widget. My database is PostgreSQL. Should I just use floats? django-geoposition? GeoDjango?
|
|
# ? Oct 29, 2014 08:52 |
|
fletcher posted:I want to store a latitude & longitude in a Django model and display the points on a Google Maps widget. My database is PostgreSQL. Should I just use floats? django-geoposition? GeoDjango? Dominoes fucked around with this message at 12:01 on Oct 29, 2014 |
# ? Oct 29, 2014 11:33 |
Right on, thanks Dominoes! I'm starting a new project using Django Rest Framework (which I've used previously) and React (which I have read about but not used yet). Any tips I should keep in mind? I think Thermopyle was doing some DRF/React stuff. Should I just have 1 Django view (index) and make it a single page app?
|
|
# ? Oct 29, 2014 23:21 |
|
fletcher posted:Right on, thanks Dominoes! I think DRF is the best at what it does, but it's still a lot of work when you go beyond the very basics. POSTing nested models just isn't worth the effort. In many ways, you're better off doing a POST to create the related model, and then a POST to create the parent model. If that's not clear I'm talking about like if you have two models, ModelOne and ModelTwo. ModelOne has a FK field to ModelTwo. It's convenient to have an API endpoint for ModelOne return the data for ModelTwo nested inside, like: code:
The POST to create a ModelOne instance after I've created ModelTwo would look like this: code:
As far as your views...you can do it any way you want. I've been transitioning a complex project over to React, and I've got multiple views. If you want to do a SPA, it's easy enough, just be aware that you'll be writing a lot of JS!
|
# ? Oct 30, 2014 05:51 |
|
Thermopyle posted:POSTing nested models just isn't worth the effort. In many ways, you're better off doing a POST to create the related model, and then a POST to create the parent model. I struggled with that recently. Good news on the DRF3 front though... https://www.kickstarter.com/projects/tomchristie/django-rest-framework-3 quote:The most pressing need for Django REST framework is a major overhaul of the serializers. This is currently the most awkward and complicated part of the project and it is in need of serious improvement. The aims of redesigning the serializers API would be:
|
# ? Oct 30, 2014 19:18 |
|
Even though your API consumer has to do more round trips, the clean separation of concerns on the backend is actually pretty nice. It makes the views and serializers simpler. If DRF3 can keep that simplicity while better handling nesting, I'll be ecstatic.
|
# ? Oct 30, 2014 21:47 |
With DRF + React, how do you get your api urls using the {% url %} tag into javascript land?
|
|
# ? Oct 30, 2014 21:49 |
|
What's everyone using for rich text input these days? I was using django-markupfield but it's not being updated for 1.7 due to architecture issues or something. Given that I'm only making a simple personal website and I've got no content up there already I'm not attached to it enough to consider rolling back to older versions of Django. Plus it'd be nice to use a fancier input widget that would show a preview mode since I tend to gently caress up the markdown syntax often. I'm looking at django-epiced since it appears to prerender the markdown text and saves the html alongside the original in the database which is something most other fields/widgets don't seem to do (not that load is going to be at all a concern, I just don't think rendering the markdown every page load is ideal considering the source text is rarely going to change), plus it actually defines a field so I don't need to do anything special to use it. I'd love other suggestions though.
|
# ? Nov 6, 2014 14:09 |
|
My ModelViewSets disappeared from the root api JSON of my Default Router. I don't know the words to google for help. What do I do guys?
|
# ? Nov 8, 2014 06:04 |
|
Storgar posted:My ModelViewSets disappeared from the root api JSON of my Default Router. I don't know the words to google for help. What do I do guys? So they were showing and then they disappeared? What did you change? For my own question....has anyone dealt with handling a writable GenericForeignKey in django-rest-framework? I can get a readable hyperlinked representation like so: Python code:
But, obviously, that doesn't work for POST'ing and today I can't think of a good way of supporting this.
|
# ? Nov 8, 2014 23:11 |
|
Thermopyle posted:So they were showing and then they disappeared? Strange... I tried messing with the url this time because before I was confident it wasn't the problem. I had this line: code:
|
# ? Nov 9, 2014 18:55 |
|
Storgar posted:Do you know what I'm doing with the parentheses? Yes. Breaking your api root view. Why do you think you need the parentheses there? I mean, I know what capturing groups do in an url regex, but why do you think you need them?
|
# ? Nov 9, 2014 19:00 |
|
Thermopyle posted:Yes. I just wanted to group the '/' and the '?'. If I wanted to apply the ? operator to more than one character, I would need the parentheses right? I figured 'api(/?)' and 'api/?' should both match 'api' and 'api/'?
|
# ? Nov 9, 2014 19:36 |
|
|
# ? Jun 1, 2024 05:18 |
|
Storgar posted:I just wanted to group the '/' and the '?'. If I wanted to apply the ? operator to more than one character, I would need the parentheses right? I figured 'api(/?)' and 'api/?' should both match 'api' and 'api/'? When you capture a group in an url regex it gets passed to the view which is the second parameter of the url function. It looks like either django or DRF is choking on this unexpected group getting passed to it. Whatever it is that is happening exactly it doesn't matter, because you don't need to do this at all. DRF will already handle urls with or without the trailing slash. Just put url(r'^api/', include(router.urls)), and you'll get your api root whether you visit blahblah.com/api or blahblah.com/api/ if you're using the SimpleRouter or the DefaultRouter .
|
# ? Nov 9, 2014 19:52 |