|
My Rhythmic Crotch posted:Been taking a break from Django for a while in order to learn more about Python and Javascript. In the meanwhile, I played with Flask, and I have to say, holy poo poo it's awesome. Part of me wants to switch my main application over to Flask, but I feel like it's probably better to stick it out and finish with Django. I just deployed a fairly small flask app with SQLAlchemy, flask-restless, and custom-rolled LDAP user auth with flask-login where most of the work is done through javascript talking to the REST API and it worked nicely. I also tried doing the same type of pattern on an app with a larger API and more views and I fell back into Django + Django REST Framework because REST Framework is awesome when you start doing things besides just exposing Models and because even if you take advantage of blueprints, breaking up Flask apps didn't really click with me. Ended up in decorator soup with lots of circular dependencies between modules. It may be possible to have a largish app in Flask, but the docs don't seem to point you in a very helpful direction (it mainly says "use blueprints, break into modules, extend the Flask object if you have to"). I'd love to see if other people are having success with it.
|
# ? Mar 1, 2013 22:00 |
|
|
# ? Jun 7, 2024 22:16 |
|
Speaking of django-rest-framework (which I also recommend), any idea how to get it to actually do a drat PATCH? It triggers the patch() method on my view (which extends generics.RetrieveUpdateDestroyAPIView, like it should), but when it gets to the `serializer.object.save()` step, it always bitches about the ID already existing. Obviously I know it exists, that's why I'm trying to update it....
|
# ? Mar 2, 2013 02:20 |
|
Got a traceback?
|
# ? Mar 2, 2013 02:23 |
|
Has anyone using Travis received this error:code:
It's gone one for over a month or something at this point, and I'm still none the wiser.
|
# ? Mar 2, 2013 13:37 |
|
ufarn posted:Got a traceback? https://gist.github.com/kennethlove/5078396
|
# ? Mar 4, 2013 07:55 |
|
For some reason, the Group model does not have an object manager. code:
Single Group objects do have a .user_set.all() attribute, but I need to retrieve the objects first. EDIT: It has a manager, but it is inaccessible. So, it appears I can access all users with Group.user_set (not .all()): code:
Python code:
code:
Single Group objects do have a .user_set.all() attribute, but I need to retrieve the objects first. EDIT: It has a manager, but it is inaccessible. So, it appears I can access all users with Group.user_set (not .all()): code:
Python code:
code:
ufarn fucked around with this message at 19:31 on Mar 5, 2013 |
# ? Mar 5, 2013 15:44 |
|
If it's an M2M like I think it is, you should be able to set the Inline model to User.groups.through, which is the invisible M2M table model. Caveat: I've not tried this specific (user/group) variant, but it's always help up for models I've made myself. Also I've not done so against 1.5 with it's AUM implementation.
|
# ? Mar 5, 2013 19:10 |
|
Yay posted:If it's an M2M like I think it is, you should be able to set the Inline model to User.groups.through, which is the invisible M2M table model. ufarn fucked around with this message at 19:38 on Mar 5, 2013 |
# ? Mar 5, 2013 19:29 |
|
Fixtures for unit tests are irritating me. Is there a good way to automatically update a fixture when you add or remove a field from a model? I am using South, which seems like it would do this, but I don't quite see how.
|
# ? Mar 7, 2013 21:25 |
|
Thermopyle posted:Fixtures for unit tests are irritating me. Don't use fixtures, use factories, like Factory Boy
|
# ? Mar 7, 2013 22:07 |
|
MonkeyMaker posted:Don't use fixtures, use factories, like Factory Boy Oh. Nice!
|
# ? Mar 7, 2013 22:42 |
|
I'm a fan of model_mommy. It lets you be a bit more hand-wavey than factory_boy, filling in fields with random data where it can.
|
# ? Mar 7, 2013 22:55 |
|
ufarn posted:For some reason, the Group model does not have an object manager. The issubclass error is also complaining that it is being passed an instance, and not a class. Have you accidentally assigned an instance of the Group class to the name "Group"? code:
|
# ? Mar 8, 2013 00:16 |
|
Found a weird little gotcha in Django. I found that form validation always failed for boolean fields if the value was set to False. If you want to accept the value of False for a boolean in a form submission, you need to define the BooleanField with required=False. However in that case you obviously will be able to assign Null to the field as well, which may not be desirable. So it turns out there is another field type called NullBooleanField. Edit: I was using a <select> with options for True and False, not the default form widget (whatever that may be) My Rhythmic Crotch fucked around with this message at 12:00 on Mar 9, 2013 |
# ? Mar 9, 2013 11:58 |
|
raymond posted:The error message is telling you that you're trying to access the manager from a Group instance, as opposed to the Group class. Python code:
Nevertheless, I think the problem was resolved. Now I just need to figure out what string value refers to the User.groups.through membership objects ("???"), so I can use it in my admin.py. ufarn fucked around with this message at 17:32 on Mar 9, 2013 |
# ? Mar 9, 2013 17:29 |
|
Looking for mile-high advice on a Django project I'm about to commence: Years ago, I made a website for a laboratory I was working with. As is usual with these things, severe mission creep set in and it ended up: * giving CRUD-like access to a database of samples, with record browsing and searching * providing tools for visualizing, comparing and working with this data in various ways * It also functioned as a CMS for various groups that used the database or were involved in lab activities, being somewhere they put reference documents, notices and so on. There was the added complication that some of the website was open to the public, and some parts only for members of particular groups. Being a Python fan, I did the site up in Plone. (Quick tip: NEVER DO THIS.) Anyway, to my surprise, the thing has worked fine for 5 years, with next to no maintenance or attention. Now, I'm between jobs and my old colleagues asked me if I can update the site. I've done some Django work in the past and from advice it seems the way to go. Any architectural / design tips welcome, especially to do with: * The access control / security is pretty important. People shouldn't see what they're not allowed to see. * In the old site, the CMS stuff lived in the Plone layer and the data records lived in a MySQL db that the Plone site accessed. Should I slam everything together in the one db, or try and keep this split? * I've been out of the loop with Django for a few years. Any new hotness that seems worth underlining? * The users really liked the edit-this-page aspect of Plone, that is admin from the user level. What's the nearest / best equivalent with Django?
|
# ? Mar 11, 2013 18:38 |
|
d3.js is probably what you want to play around with for visualizations.
|
# ? Mar 11, 2013 18:45 |
|
Anyone else at PyCon? I'm giving a tutorial today (Wiring Up Django Packages at 1:10pm) but I'll be around until Monday. Real name is Kenneth Love, if you see me, say hi.
|
# ? Mar 14, 2013 16:52 |
|
MonkeyMaker posted:Anyone else at PyCon?
|
# ? Mar 14, 2013 16:59 |
|
MonkeyMaker posted:Anyone else at PyCon? I'm here with a co-worker but we signed up for that parallel computing tutorial. I think a crapton of #cobol'rs on irc are coming on friday though
|
# ? Mar 14, 2013 18:47 |
|
To rephrase my former question, what is the field name to use to organize my M2M users from my group model in here? I am trying to display them using filter_horizontal, so it doesn't look like arse.
|
# ? Mar 18, 2013 18:43 |
|
RIP Malcolm Tredinnick (source) One of the first persons to answer a question for me on #django was Malcolm, I actually feel sad.
|
# ? Mar 20, 2013 18:49 |
|
Have you guys seen Andrew Godwin's Schema Migrations Kickstarter? http://www.kickstarter.com/projects/andrewgodwin/schema-migrations-for-django/ Andrew built South; The best, and only, schema migration tool for Django. His Kickstarter is part of his proposal to build a migration system directly into Django core, finally filling the gaping hole when it comes to migrating models. The Kickstarter reached its goal of £2,500 in just one hour, reaching all its stretch goals in 4 hours. It currently sits at £15,600 with 10 days to go. Hopefully it gets above 20K because Andrew deserves every penny. So if you've struggled with manual schema migrations, have used South in the last 4 years, or are new to Django and are going to encounter schema migrations very soon, you should consider pledging a few bucks. (PS: I accidentally posted this in the main software thread, so ignore the redundancy.)
|
# ? Mar 27, 2013 01:02 |
|
deimos posted:RIP Malcolm Tredinnick (source) Yeah, I was sad to hear about his passing too. He did a LOT for Django and the ORM. This is a video of him at DjangoCon 2012, doing a 4 year recap of the ORM based off his talk from the very first DjangoCon (which I was fortunate enough to be able to attend): https://www.youtube.com/watch?v=bgV39DlmZ2U Also there's this sad update to the committers list. https://github.com/django/django/commit/f02c6c27600c6e78b3f4bb3447cfc025a1f27a90 Zamtools fucked around with this message at 01:17 on Mar 27, 2013 |
# ? Mar 27, 2013 01:07 |
|
Zamtools posted:Have you guys seen Andrew Godwin's Schema Migrations Kickstarter? Thanks for posting that, just made my donation. South has been the first app to install on any new Django project I've worked on for the past year or two. It'll be great to get support into mainline Django.
|
# ? Mar 27, 2013 15:55 |
|
Zamtools posted:and only There are others (nashvegas, django-evolution, etc) but they're best not mentioned unless you have specific needs.
|
# ? Mar 27, 2013 16:55 |
|
Zamtools posted:Have you guys seen Andrew Godwin's Schema Migrations Kickstarter? quote:Better merge detection. The new migration format means that merging between different VCS branches will no longer need any work or extra migrations, provided the changes are mergeable. Yes, please! Migrations and git just don't work very well together.
|
# ? Mar 27, 2013 22:34 |
|
There's just 38 hours remaining on the Schema Migrations kickstarter: http://www.kickstarter.com/projects/andrewgodwin/schema-migrations-for-django/ I'm hoping the pledges get up to £20K. Every bit of extra cash is going to ensure more time can be spent on, what could arguably be considered, one of the most important missing features in Django.
|
# ? Apr 4, 2013 23:16 |
|
What's the best place to learn django as of now? The OP suggests The Django Book, but some googling shows me that that was written for 1.0, and not to use it? So far I've done the microblog thing on the django site, and the 3 videos that are up at http://gettingstartedwithdjango.com/. What's the next step? I liked the GSWD videos, but unfortunately they release them really slow.
|
# ? Apr 7, 2013 23:40 |
|
mmm11105 posted:What's the best place to learn django as of now? The OP suggests The Django Book, but some googling shows me that that was written for 1.0, and not to use it? So far I've done the microblog thing on the django site, and the 3 videos that are up at http://gettingstartedwithdjango.com/. What's the next step? I liked the GSWD videos, but unfortunately they release them really slow. There is also an ED PyCon video that goes over three hours, and I found it to be incredibly dull to watch, although I wasn't exactly the target demographic.
|
# ? Apr 7, 2013 23:48 |
|
mmm11105 posted:What's the best place to learn django as of now? The OP suggests The Django Book, but some googling shows me that that was written for 1.0, and not to use it? So far I've done the microblog thing on the django site, and the 3 videos that are up at http://gettingstartedwithdjango.com/. What's the next step? I liked the GSWD videos, but unfortunately they release them really slow. I'm trying to go faster, dammit! Glad you liked them.
|
# ? Apr 8, 2013 16:48 |
|
I've got a form for creating a model instance. Sounds like a perfect use for a CreateView along with a ModelForm. Easy as pie, right as rain, like shooting fish in a barrel, etc. However, there's a two-part wrinkle...
All the objects have the same data for all the fields except for a "name" field which can consist of identifiers like 'A' or '112'. I got tired of trying to chase mixins and class hierarchies around to figure out how to do it with a CBV + ModelForm, so what I'm doing now is using:
My questions are...should I give up on the dream of implementing this with CreateView and a ModelForm? Maybe it's possible but my FBV + Form is just an easier/better way of doing it instead of torturing a CBV + ModelForm into doing what I want?
|
# ? Apr 8, 2013 17:13 |
|
Thermopyle: where is it failing? I'm sure it can be done, but without a bit more info, can't really help. First steps would probably be making sure some fields can be null/blank in the form & model, and then overriding `form_valid` in the view.
|
# ? Apr 8, 2013 17:51 |
|
MonkeyMaker posted:Thermopyle: where is it failing? I was afraid someone would say this. I'll whip up a test project...
|
# ? Apr 8, 2013 19:36 |
MonkeyMaker posted:I'm trying to go faster, dammit! Make new episodes faster, but transition from screen-to-screen after editing code slower! Really love the videos so far as someone with programming experience but limited python/web development. Any set plans for the topics of upcoming episodes?
|
|
# ? Apr 8, 2013 20:00 |
|
MonkeyMaker posted:Thermopyle: where is it failing? Thermopyle posted:I was afraid someone would say this. I'll whip up a test project... https://github.com/therms/CBV-custom-modelform-test The relevant bits are in test_app/forms.py and test_app/views.py. Forget everything I just wrote above about not being able to get this working. Working on a new project helped clear my mind and I figured it out. The parse_multi_name method in ClassBForm is just a simple place holder for a more robust library I wrote. When you visit class_b/add/1/ the form removes the field for selecting a foreign key and uses FK 1. Would anyone mind looking at forms.py and views.py and give me their thoughts on how I handled this? (if you want to mess around with the admin the user/pass is admin/admin)
|
# ? Apr 8, 2013 21:30 |
|
MonkeyMaker posted:I'm trying to go faster, dammit! No problem, thanks for the great videos. While django does have a nice docs site, it still has a dearth of learning resources compared to rails (I just like python a lot better than ruby). Any word on the timing for the next episode?
|
# ? Apr 8, 2013 22:18 |
|
Thermopyle posted:https://github.com/therms/CBV-custom-modelform-test Some notes: You *should* be able to get your FK in dispatch instead of doing it twice in get/post code:
|
# ? Apr 8, 2013 22:28 |
|
KingNastidon posted:Make new episodes faster, but transition from screen-to-screen after editing code slower! Really love the videos so far as someone with programming experience but limited python/web development. Any set plans for the topics of upcoming episodes? 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). If that doesn't fill up that many episodes, I'll come up with some other small project after that. Then there'll be a few more episodes covering other areas of Django development, like standing up servers on AWS and building search with Haystack. As for a release schedule, I'm working on episode 4 already, so expect a video in a week or so.
|
# ? Apr 8, 2013 22:33 |
|
|
# ? Jun 7, 2024 22:16 |
|
MonkeyMaker posted:Some notes: Ahh, nice. Thank you. 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). I'm excited!
|
# ? Apr 9, 2013 01:10 |