|
MonkeyMaker posted:To answer both you and mmm11105 (and sorry for the double post), I do have a set plan for the future episodes. The next 7 or 8 will all focus on building one large app. It'll be set up as an app for tracking things you've loaned to friends/family. We'll obviously stretch the use case a little, but it'll include things like Celery, sending emails, manipulating images, and setting up an API to use with a Javascript frontend (we *might* scratch this, but I doubt it). For what its worth, a video detailing setting up an API to use with any kind of front-end would be awesome as I have been having a hard time locating a current and comprehensive/understandable resource for a stupid side project that I have almost finished except for that part. I would additionally like to thank you because the videos are top notch for an idiot code newbie such as myself.
|
# ? Apr 9, 2013 03:20 |
|
|
# ? Jun 5, 2024 20:51 |
|
I'm trying to get back into Django, and I'm finding it hard to not hate forms. What is the modern make-Forms-better library?
|
# ? Apr 9, 2013 03:57 |
|
Django crispy forms comes highly recommended. It looks good but I have yet to try really working with it.
My Rhythmic Crotch fucked around with this message at 09:27 on Apr 9, 2013 |
# ? Apr 9, 2013 09:21 |
|
Sinestro posted:I'm trying to get back into Django, and I'm finding it hard to not hate forms. What is the modern make-Forms-better library? django-crispy-forms for form control. django-floppyforms for HTML5 widgets.
|
# ? Apr 9, 2013 17:43 |
|
More of a curiosity than anything here but I figure it is worth asking about. I've got a page iterating through some database objects in a standard django template for loop using "reversed." Locally, using sqlite3, this makes the items show up with the most recently created item at the top but on my "live" version over on Heroku, running postgres, it does the opposite. Is this due to the databases being different or something else?
|
# ? Apr 14, 2013 03:23 |
|
The March Hare posted:More of a curiosity than anything here but I figure it is worth asking about. I've got a page iterating through some database objects in a standard django template for loop using "reversed." Locally, using sqlite3, this makes the items show up with the most recently created item at the top but on my "live" version over on Heroku, running postgres, it does the opposite. There is no guaranteed order for a result set from postgres unless you specify ORDERY BY. Take a look at https://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by Also you really should run the same database in development as in production.
|
# ? Apr 14, 2013 04:06 |
|
Pardot posted:There is no guaranteed order for a result set from postgres unless you specify ORDERY BY. Take a look at https://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by Cool, good to know. Additionally, I'm sure that link has some useful info in it and I can certainly see how normalizing things would be beneficial in most if not all situations, but that page needs to be rewritten by someone less evangelical -- poo poo reads like the label of a Dr. Bronner product.
|
# ? Apr 14, 2013 04:38 |
|
When's more DjangoCon US info gonna get posted? I'm still suffering from jealousy at my coworkers' trip to Pycon.
|
# ? Apr 24, 2013 17:58 |
|
etcetera08 posted:When's more DjangoCon US info gonna get posted? I'm still suffering from jealousy at my coworkers' trip to Pycon. Usually after DjangoCon EU starts/wraps. What we know so far: * Likely to be first week of September since that's been the date for a few years now * It'll be in Chicago in 2013 * If there's public voting for talks, I expect all the goons to back mine EDIT: They've put up a placeholder site: http://2013.djangocon.us/ and set the dates as Sept. 2nd through 7th. MonkeyMaker fucked around with this message at 17:58 on May 1, 2013 |
# ? Apr 24, 2013 18:24 |
|
I'm working on a basic asset tracking system and I need to keep track of different item types. Simple enough except that some item types are also "containers" and can only contain certain item types. I need to enforce this restriction and have reverse lookups indicate what an item type can be placed in. Would I be correct in using a model with a man-to-many field referencing itself? For example a computer can "contain" a DVD, but a DVD can also be placed in a DVD player or DVD case. I have the the following code but I feel like i'm missing something. code:
I've been messing around a bit and i've come up with something that almost does everything I need: code:
code:
I need to do the reverse as well: code:
EDIT #2: Using the same models as above, I think I may have found the answer, but I have a nagging feeling that there is a "gotcha" somewhere: code:
bigmandan fucked around with this message at 21:50 on May 7, 2013 |
# ? May 7, 2013 17:45 |
|
MonkeyMaker posted:Usually after DjangoCon EU starts/wraps. What we know so far: Can you share what your talk will be about? Maybe I'll actually attend this time!
|
# ? May 8, 2013 15:40 |
|
bigmandan posted:
Not answering your question, but don't do leading commas like that. This isn't Javascript with lovely parsers that can't handle a trailing comma. Learn, love, and live PEP8 please. To answer your question, your final approach doesn't look horrible. You might look into something like django-mptt, though, to make categorization easier. @avidal: Not 100% certain yet but I have two I plan to propose. One about using django-rest-framework with AngularJS (including a live code demo! (which, like an intelligent person, I will write beforehand)). Second about lessons learned doing Getting Started with Django, both on 'how to run a kickstarter and get community support for your idea' and 'how to teach noobs things'. I have another idea or two kicking around too.
|
# ? May 9, 2013 18:45 |
|
Thanks MonkeyMaker. I fixed my dumb commas too. I am already using django-mptt for categorization, but I trimmed my example to illustrate my particular concern and I should have stated that.
|
# ? May 9, 2013 20:52 |
|
So I'm trying to run through GSWD but I'm having some issues at the very beginning. Some guy on the forums over there had the same problem two days ago (http://gettingstartedwithdjango.com/questions/1/errors-running-vagrant-up/) and hasn't gotten any responses, so I figured I'd try here. When I do my "vagrant up" I get some errors: Recipe Compile Error in /tmp/vagrant-chef-1/chef-solo-1/cookbooks/yum/resources/key.rb wrong number of arguments (2 for 1) If it helps, the link above to the GSWD forums has the full output of the command and the stacktrace which is the same thing I'm getting. Let me know if any additional info would be helpful.
|
# ? May 10, 2013 00:01 |
|
Kumquat posted:So I'm trying to run through GSWD but I'm having some issues at the very beginning. Some guy on the forums over there had the same problem two days ago (http://gettingstartedwithdjango.com/questions/1/errors-running-vagrant-up/) and hasn't gotten any responses, so I figured I'd try here. Sorry, been sick for a couple of days. As I answered him (just now), is this the first time or subsequent times? Actually, just check out the answer I gave him. You can hit me up on IRC too in #cobol
|
# ? May 10, 2013 00:28 |
|
I've been away from Django for a while and since coming back I'm trying to get my head around class based views (It was only function based when I last played with Django). Does anyone have recommendations for good tutorials, info, etc. on testing class based views? Are they tested in the same way as function based views? I feel like there should be a different testing approach, but that may be because I'm getting hung up on the 'class' part of class based views. Thanks in advance.
|
# ? May 11, 2013 11:57 |
|
I'm thinking about deployment of a django project. Heroku is very tempting because if how easy it is (why didn't I try this out before?), however I'm looking to get some feedback from people who've got more sites and more high-traffic sites deployed and what they think about Heroku performance and the Rap Genius debacle. Big deal or not?Lister_of_smeg posted:I've been away from Django for a while and since coming back I'm trying to get my head around class based views (It was only function based when I last played with Django). Does anyone have recommendations for good tutorials, info, etc. on testing class based views? Are they tested in the same way as function based views? I feel like there should be a different testing approach, but that may be because I'm getting hung up on the 'class' part of class based views. Just test them. I think you're getting hung up on them being different from what you're used to. You just test their parts and test their functionality. How exactly do you foresee the tests being different? Thermopyle fucked around with this message at 17:57 on May 13, 2013 |
# ? May 13, 2013 17:54 |
|
Lister_of_smeg posted:I've been away from Django for a while and since coming back I'm trying to get my head around class based views (It was only function based when I last played with Django). Does anyone have recommendations for good tutorials, info, etc. on testing class based views? Are they tested in the same way as function based views? I feel like there should be a different testing approach, but that may be because I'm getting hung up on the 'class' part of class based views. CBVs aren't all that different from FBVs except in a couple of places. How you call them from your URL routes, and how you inject functionality. Say you have a CBV named PostListView. In your urls.py, instead of `'path.to.post_list_view'`, you'd have `PostListView.as_view()` for the function part of the route (after the regex, before the name). And then, to change functionality, you'd override a method in the view instead of just adding code to a giant function. http://ccbv.co.uk is probably the best guide to what methods already exist for you to override and change. But, really, CBVs work just like all other classes in Django and Python. Create a new class, extend it off of an existing one, override the methods and attributes that you need to, and you're done. Testing is just like FBVs. Call the view, ideally through `self.client`, and check the response's status code, template, etc. If you want to test individual methods, instantiate the class with a request object and go to town.
|
# ? May 13, 2013 18:30 |
|
Heroku is alright, if you don't plan on going big - will you realistically need to do horizontal scaling on the project? That, and not to use Relic's bullshit metrics, is the main take-away here. That and Heroku's lovely handling of the entire situation. You don't have to be married to Heroku; django-deployer should keep you independent, as long as you don't rely on postinstall/post-deploy scripts, which aren't supported on Heroku, IIRC.
|
# ? May 13, 2013 18:35 |
|
Thermopyle posted:I'm thinking about deployment of a django project. Heroku is very tempting because if how easy it is (why didn't I try this out before?), however I'm looking to get some feedback from people who've got more sites and more high-traffic sites deployed and what they think about Heroku performance and the Rap Genius debacle. Big deal or not? The Rap Genius debacle existed mostly because Rails is a single threaded app. Each dyno can only handle 1 request at a time and any other requests sent to that dyno will be queued by the OS. If you deploy Django with a good server like Gunicorn or uwsgi you'll get atleast a few requests concurrency per dyno, or if you use an event driven archecture (gunciron with gevent/eventlet for instance) you'll get thousands of requests work of concurrency per dyno. This effectively nulls the problem Rap Genius had.
|
# ? May 14, 2013 02:59 |
|
Steampunk Hitler posted:The Rap Genius debacle existed mostly because Rails is a single threaded app. Each dyno can only handle 1 request at a time and any other requests sent to that dyno will be queued by the OS. If you deploy Django with a good server like Gunicorn or uwsgi you'll get atleast a few requests concurrency per dyno, or if you use an event driven archecture (gunciron with gevent/eventlet for instance) you'll get thousands of requests work of concurrency per dyno. This effectively nulls the problem Rap Genius had. Eh, wasn't the whole thing mostly about the 'intelligent' routing that doesn't really exist? Anyways. Anybody at Djangocon EU?
|
# ? May 14, 2013 14:09 |
|
Mulozon Empuri posted:Eh, wasn't the whole thing mostly about the 'intelligent' routing that doesn't really exist? As far as I can understand it's a combination of that with the problem that Steampunk Hitler mentioned. Since Rails can handle only 1 request, and since Heroku's routing is dumb, Heroku would route a request to a dyno that was waiting on rails instead of routing to dyno's that were just idling. I didn't even realize you could use eventlet workers with gunicorn, which means that while a dyno is waiting on I/O it can serve other requests.
|
# ? May 14, 2013 17:44 |
|
Thanks Thermopyle and MonkeyMaker. As I suspected I was getting hung up on the class part. I kept thinking "Hey, this is a Python class. Let's unit it test it like a class." rather than thinking "Hey, this is a slightly different way of implementing a view. Test it like you do with other views". Also, http://ccbv.co.uk is fantastic.
|
# ? May 14, 2013 19:31 |
|
Can I get a sanity check on this... it does what I want, but I'm paranoid that I'm doing something that may bite me in the rear end in the future. Basically I am building forms through mixins, but one of the mixins does multi-field validation, so I'm calling super.clean() first in my clean method on the form:Python code:
|
# ? May 17, 2013 17:05 |
|
Some semantical stuff: I recommend that mixins should only inherit from object. By definition, a mixins only purpose is to provide a small number of features to multiple other classes. By inheriting from Form, you're getting a ton of other methods and attributes which will make behavior of classes using those mixins more difficult to reason about. (Great advice from Kenneth Love, actually) From the looks of it, I don't think those are actually mixins by the common definition. Anyway, it doesn't really matter where you put your call to the super's clean method as long as you're aware of what the super is doing. If your code makes modifications to data that you then want the super's clean method to validate, than you put it at the end, if you want the super's clean method to validate before then you put it at the end. You can put it right in the middle if you want the super to validate before your own validation code continues. From what I can tell, you're fine in that regard.
|
# ? May 17, 2013 17:28 |
|
Thermopyle posted:Some semantical stuff: I recommend that mixins should only inherit from object. By definition, a mixins only purpose is to provide a small number of features to multiple other classes. By inheriting from Form, you're getting a ton of other methods and attributes which will make behavior of classes using those mixins more difficult to reason about. (Great advice from Kenneth Love, actually) From the looks of it, I don't think those are actually mixins by the common definition. Thanks. And yes, they aren't "really" mixins, and are not actually called that in my code (the actual names are Base____Form) since they can be (and are) used standalone Forms as well. I changed the names in my example to make it more clear what I was doing.
|
# ? May 17, 2013 18:20 |
|
Thermopyle posted:(Great advice from Kenneth Love, actually) D'awww. And, yeah, Thermopyle has it right. `super()` is just to invoke a function from a superclass, so it can (and should) be called from wherever it's needed.
|
# ? May 17, 2013 18:24 |
|
It's my first five minutes looking at Django and this thread, but the OP is foobar (at least the images and some links), in case anyone cares.
|
# ? May 20, 2013 13:21 |
|
supermikhail posted:It's my first five minutes looking at Django and this thread, but the OP is foobar (at least the images and some links), in case anyone cares.
|
# ? May 20, 2013 13:42 |
|
ufarn posted:It also doesn't have syntax-highlighting, which was introduced after the post. I see.
|
# ? May 20, 2013 14:25 |
|
ufarn posted:It also doesn't have syntax-highlighting, which was introduced after the post. It is also 5 years old, which means it was written around version 1.0, so it's woefully out of date.
|
# ? May 20, 2013 14:40 |
|
New OP:quote:Django tutorial
|
# ? May 20, 2013 20:08 |
|
Double postin' like a crazy man. What's the right way to access Django settings from a non-Django script? Specifically, I have some periodic celery tasks in which I'd like to use Django's LOGGING config. Right now, I'm reading DJANGO_SETTINGS_MODULE from the environment variable and importing LOGGING and using dictConfig to configure my logger, but it kind of feels like that since I'm using django-celery there should be something else. But then again, this is my first time using it so I may just be wrong.
|
# ? May 21, 2013 01:59 |
|
I personally store my settings as MYSETTING = os.environ.get('MYSETTING', "DEFAULT_VALUE") I don't think there's any sexy way to store and retrieve settings, if that's what you're asking.
|
# ? May 21, 2013 02:05 |
|
Thermopyle posted:Double postin' like a crazy man. Shouldn't you be able to run Celery Beat and Celery through Django when you have the django-celery installed? That way you should be able to make use of django.conf.settings, yeah? edit: It's something like python manage.py celery worker for development. For production you need daemonize the process yourself (http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html#starting-the-worker-process) I don't have my full setup on hand right now, but in one of my applications I'm just importing whatever I like from tasks.py in a Django app without any dramas. Maluco Marinero fucked around with this message at 02:31 on May 21, 2013 |
# ? May 21, 2013 02:28 |
|
Maluco Marinero posted:Shouldn't you be able to run Celery Beat and Celery through Django when you have the django-celery installed? That way you should be able to make use of django.conf.settings, yeah? Yeah, this is pretty much it.
|
# ? May 21, 2013 20:06 |
|
Yeah, I'm a dummy. I was only having problems because while testing I was just running my script from the command line, which obviously doesn't work. And by obvious I mean obvious after you go to bed and wake up.
|
# ? May 21, 2013 22:23 |
|
I am the worst Googler in the world, apparently. I have a class-based FormView, which has SomeForm as it's form_class. How on earth do I set a cookie at any point in either for view or the form. Preferably the form, but I don't care at this point.
|
# ? May 22, 2013 16:30 |
|
Lumpy posted:I am the worst Googler in the world, apparently. What do you mean by "set a cookie"? Like pass in a kwarg to the form? code:
|
# ? May 22, 2013 19:15 |
|
|
# ? Jun 5, 2024 20:51 |
|
MonkeyMaker posted:What do you mean by "set a cookie"? Like pass in a kwarg to the form? No, i mean use the request.set_cookie("key", "value", 1000) method to set a cookie so I can read it in the future. Or is there some other way to do that?
|
# ? May 22, 2013 20:53 |