|
LuckySevens posted:Yeah, I just wrote the view myself, everything works smoothly now except: Did my suggestion not work? If your series field was a ForeignKey, then you could use self.series.slug. But your series field is a ManyToMany field, and your video is linked to possibly more than one VidSeries. It needs to pick just 1 of them so it can make up a URL. Read this if you haven't already: http://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.permalink
|
# ? May 13, 2010 14:47 |
|
|
# ? May 15, 2024 02:07 |
|
Oh sorry, totally missed your last post for some reason. That suggestion works, thanks for that, I'm understanding now the philosophy behind it now.
|
# ? May 13, 2010 17:06 |
|
Is anyone familiar with initial_data? I've reviewed the docs on it and it seems straightforward enough, but I can't get it to work. I've got a file called initial_data.yaml, it looks like this: code:
Where am I going wrong?
|
# ? May 15, 2010 00:18 |
|
Sock on a Fish posted:Figured it out, Django doesn't even try to deserialize YAML if PyYAML isn't installed. Installed PyYAML, got another error about invalid model name, used dumpdata to find that the actual name is 'auth.group', and now everything works proper.
|
# ? May 15, 2010 00:32 |
|
inveratulo posted:This is really a better way of thinking about things than how I was going about it. But it still doesn't address the edge cases of say when I want a job to run daily, except on Sundays. Any other suggestions? If I can create a model to select a single value from a list, I should be able to create a model that select multiple values from a list without having to hack the form route, right?
|
# ? May 18, 2010 15:25 |
|
Not sure if I'm being to clever here or not clever enough, trying to design a menu templatetag based on tree of my manytomany linked models, by returning the titles into a tree-like dictionary queryset:code:
edit: code revised and tested, now delivers the tree dict structure i want LuckySevens fucked around with this message at 20:32 on May 18, 2010 |
# ? May 18, 2010 19:37 |
|
LuckySevens posted:Any foreseeable problems doing it this way? An entirely opposite approach: use generic relations to tie an object (of any type) to a 'MenuItem' model; provide a context processor or templatetag to fetch. Can be taken from project to project, extending as you need it. An even more opposite approach: find a re-usable app that does what I just said. inveratulo posted:Any other suggestions? If I can create a model to select a single value from a list, I should be able to create a model that select multiple values from a list without having to hack the form route, right?
|
# ? May 18, 2010 21:31 |
|
Yay posted:Its certainly a bit more tricky; I'm pondering it. I suppose the problem is, that doing it every X but not Y isn't massively useful; it mostly only applies to days. For example, performing a ScheduledJob every month, but not March, isn't likely. Its mostly days its appropriate to. Well, I am trying to create something that can hold its own with crontab, hopefully replacing it entirely in the future. What I ended up doing was creating a day and month object, and generating 7 and 12 instances of each, respectively. Then my job objects have a many-to-many relationship with these days or months. 9am and 3:30pm every second and third Tuesday of months not ending in a "-ember"? Not a problem! e: i may put in a schedule object layer and have my jobs subscribe to them. So I can have like, multiple jobs subscribed to a daily midnight job or something like that.
|
# ? May 19, 2010 13:26 |
|
Does anyone use fabric? I'm trying to get fabric, in one operation, to selectively apply certain sub-operations only to a subset of hosts. e.g., when deploying I want to copy new files to all application servers, but I only want to syncdb, do a south migration, and install some cron jobs on one host. I tried to accomplish this by defining two roles, one 'primary_host' that updates the db and has cron jobs, and another 'whole_cluster' that consists of every app server. I've got one function that's decorated with an @roles('primary_host') that contains calls to a bunch of other functions, some which are decorated the same and some which are decorated @roles('whole_cluster'). The problem is, when I run that one big function, the actions are only performed on the primary_host. Am I doing this wrong, or is this a limitation of fabric? Right now it seems like I'm going to have to write a shell script that calls fabric with different host arguments.
|
# ? May 20, 2010 17:00 |
|
Eh, wasn't that bad, I'd still like to keep it all in Fabric if that's what I'm using anyway:code:
|
# ? May 20, 2010 17:43 |
|
Sock on a Fish posted:The problem is, when I run that one big function, the actions are only performed on the primary_host. Am I doing this wrong, or is this a limitation of fabric? Limitation of Fabric: http://code.fabfile.org/issues/show/21 (a generic ticket, but covers this overall issue to some degree.) There will be some way to do it in the future (e.g. execute('function_name', ['host', 'list'])) but right now it's not easily possible. You can fake it on your own for the time being by routing around the main execution loop: when run() and sudo() execute, they actually just check env.host_string. Multi-host execution (either manual or in Fabric's own main loop) is thus just effected by looping over a host list and setting that variable, then calling the task function. So you could do e.g. code:
code:
Hope that makes some sense.
|
# ? May 20, 2010 19:51 |
|
So they announced djangocon. I was thinking of going until Is saw how much it costs. Five hundred freaking dollars per person. Why does it cost so much? I haven't been to a "con" like this before, but that seems like a lot of money. I've been to job fairs before that costs $100 which I thought was a lot, even though the price included a fancy catered lunch. Does Djangocon at least include kick rear end food? If one hundred people show up, thats $50,000 of gross income. Does it really costs that much money put put on a "con" of this nature?
|
# ? May 20, 2010 23:12 |
|
Does anyone have any suggestions for how I can catch the non-hashed password when a user updates their password? I need to sync it with Convio and I've been using signals for catching profile changes. The changed password is the only real stumbling block I have left on this point.
|
# ? May 20, 2010 23:27 |
|
MonkeyMaker posted:Does anyone have any suggestions for how I can catch the non-hashed password when a user updates their password? I need to sync it with Convio and I've been using signals for catching profile changes. The changed password is the only real stumbling block I have left on this point. Firstly, you shouldn't be storing unhashed passwords - I'm assuming you want to put the password into an API which hashes it internally. First, look for a way of passing in the hashed password. Failing that, you could just extend the registration form and add a hook in for what you want to do - I don't know what the best practices for that would be though I'm sure someone else will.
|
# ? May 20, 2010 23:52 |
|
Jonnty posted:Firstly, you shouldn't be storing unhashed passwords - I'm assuming you want to put the password into an API which hashes it internally. First, look for a way of passing in the hashed password. Failing that, you could just extend the registration form and add a hook in for what you want to do - I don't know what the best practices for that would be though I'm sure someone else will. I'm not storing an unhashed password anywhere. I'm sending it, securely, to Convio who will hash it in their own way and store it. The registration form won't help me either since I only care, at this point, about password changes. I'm sure I could write my own view for it, or edit Django's existing view, but I'd really rather not since that fucks with forward-compatability.
|
# ? May 21, 2010 00:44 |
|
MonkeyMaker posted:Does anyone have any suggestions for how I can catch the non-hashed password when a user updates their password? I need to sync it with Convio and I've been using signals for catching profile changes. The changed password is the only real stumbling block I have left on this point. I'd look into modifying the form field to send the value off somewhere in the clean() function. Sounds really dirty though (sending off plain text passwords that is) Or maybe have an ajax request send the password off by scraping it off the text field in the HTML.
|
# ? May 21, 2010 02:21 |
|
nbv4 posted:So they announced djangocon. I was thinking of going until Is saw how much it costs. Five hundred freaking dollars per person. Why does it cost so much? I haven't been to a "con" like this before, but that seems like a lot of money. I've been to job fairs before that costs $100 which I thought was a lot, even though the price included a fancy catered lunch. Does Djangocon at least include kick rear end food? If one hundred people show up, thats $50,000 of gross income. Does it really costs that much money put put on a "con" of this nature? I don't know why you're putting "con" in quotes. But to your question; I've found most python conferences well worth the price of admission - but I would note that prices of the DjangoCon tickets is surprising to me. Tickets to a lot of conferences have been going up though - and typically, the tickets are not profitable to the organizers - the money goes to pay for the hotel rooms and costs, and the most expensive item - food and snack catering. Really, seeing behind the scene at Pycon as I have, it doesn't surprise me to see expensive tickets (even if the cost is more than I'd expect) for DjangoCon - the hotels (and especially, the catering people) love to stick it in your throat whenever they can. So, essentially I can see justification for the price from a pure contract-with-the-hotel-and-catering-people standpoint, I imagine the organizers found the best hotel deal they could (or were locked into a multi year contract) and are paying for it now. Unless you're in a good negotiating position, hotels and the other groups will totally molest you. As for "will the content be worth it" - I don't even miss a beat when I say yes. It will be. Like PyCon, the content will be high quality, there will be a lot of it, and you will get the best thing ever out of it - exposure to other people working with it. The networking, sprinting and hallway track is almost worth it alone.
|
# ? May 21, 2010 03:04 |
|
My boss is running the conference, so I'll say what I can. Basically there are a LOT of holdover contracts this year that they couldn't renegotiate.
|
# ? May 21, 2010 04:46 |
|
MonkeyMaker posted:Does anyone have any suggestions for how I can catch the non-hashed password when a user updates their password? I need to sync it with Convio and I've been using signals for catching profile changes. The changed password is the only real stumbling block I have left on this point. This is totally untested but you could try putting this, or something like it, into an __init__.py file of an installed app. It could be extended to work with more than just the set password form. I suppose it could break in future versions of django, but it's less likely to break than replacing code. code:
raymond fucked around with this message at 11:19 on May 21, 2010 |
# ? May 21, 2010 11:14 |
|
Hey guys, I am having problems with the admin model that I am overriding. Basically, in my models.py I have something this:code:
code:
|
# ? May 21, 2010 15:02 |
|
bitprophet posted:Hope that makes some sense. Perfect sense, thanks. That reminds me of figuring out that the cd() context manager doesn't process absolute paths correctly, so before every cd('/some/abs/path') I'd have to set env.cwd to ''.
|
# ? May 21, 2010 22:06 |
|
Sock on a Fish posted:Perfect sense, thanks. That reminds me of figuring out that the cd() context manager doesn't process absolute paths correctly, so before every cd('/some/abs/path') I'd have to set env.cwd to ''. Hmm. That should only be the case if env.cwd is set to a non-empty value beforehand, such as if you were to call cd within another cd block. Can you verify whether that's what's going on? Edit: If we have to do more than another back-and-forth on this, given it's not that Django related, maybe I should make a Fabric thread. Then again I can't imagine that many goons use it, so maybe we should just take it to email or PM.
|
# ? May 22, 2010 00:20 |
|
inveratulo posted:Hey guys, I am having problems with the admin model that I am overriding. Basically, in my models.py I have something this: Just a stab in the dark, but maybe try changing your JOB_PERIOD tuple to use numbers instead of strings (change '0' to 0, '1' to 1, etc). I think Django converts your string numbers fine when saving the model, but when loading the model from the database it gets back integers.
|
# ? May 22, 2010 00:31 |
|
bitprophet posted:Hmm. That should only be the case if env.cwd is set to a non-empty value beforehand, such as if you were to call cd within another cd block. Can you verify whether that's what's going on? Oh yeah, it was a cd within a cd. I had some functions that were executing other functions within a cd context, and within those functions themselves there was a cd context specified as well. That really threw me, I assumed that any path starting with '/' would be interpreted as absolute.
|
# ? May 23, 2010 07:58 |
|
Sock on a Fish posted:Oh yeah, it was a cd within a cd. I had some functions that were executing other functions within a cd context, and within those functions themselves there was a cd context specified as well. That really threw me, I assumed that any path starting with '/' would be interpreted as absolute. Thanks, that makes sense now, and I agree that your assumption should have been correct. Ticket
|
# ? May 23, 2010 13:40 |
|
raymond posted:Just a stab in the dark, but maybe try changing your JOB_PERIOD tuple to use numbers instead of strings (change '0' to 0, '1' to 1, etc). I think Django converts your string numbers fine when saving the model, but when loading the model from the database it gets back integers. Thanks Raymond this worked like a charm.
|
# ? May 24, 2010 12:47 |
|
So.. Shopping apps in Django? I've found LFS and Satchmo so far. Any of you guys have any experience with those two? Any other shop apps I should be checking out?
|
# ? May 25, 2010 09:44 |
|
One of the guys I work with use{d,s} a forked, very early Satchmo, successfully. In general the satchmo guys seem pretty smart, but that's as much as I can intelligibly say.
|
# ? May 25, 2010 10:03 |
|
Cool, thanks for the feedback. I need to get away from the horror that is a site build on Joomla. Now I've just got to convince people that Python/Django is a valid choice.
|
# ? May 27, 2010 17:14 |
|
Is it worth using one of the Django blogging packages out there or would it be just as simple to write one myself? I know Django well enough, but I'm not sure what malarkey people put in their Django-based blogs, so maybe it'd be a lot of work to write a decent one! Corollary: if I should use one of the already-existing ones, which one is least bad? (I have had less than stellar experiences with stuff built on top of Django.)
|
# ? Jun 3, 2010 02:52 |
|
Avenging Dentist posted:Is it worth using one of the Django blogging packages out there or would it be just as simple to write one myself? I know Django well enough, but I'm not sure what malarkey people put in their Django-based blogs, so maybe it'd be a lot of work to write a decent one! A lot of people recommend rolling your own. But come on, it's 2010, and a blog has a bunch of features (pingbacks, feeds) that we shouldn't have to waste our rewriting.
|
# ? Jun 3, 2010 08:26 |
|
NoDamage posted:(django-mingus, the first installation step in a loving blog shouldn't consist of installing 30 other plugins) In its author's defense, the point of Mingus is to embrace the Django "reusable apps" philosophy. It's not that they're plugins to some core app, it's that the core app is simply a tiny bit of glue to hold all of the individual components together. So where e.g. Wordpress core implements comments, static pages, permalinks, RSS feeds, and so forth, and then has plugins, Mingus is just a collection of what its author perceives to be the best available Django comments app, permalink app, RSS feed app, etc. So to knock it for "requiring a bunch of plugins" is to miss the point of the app. At least, that's my understanding; I haven't used it myself, only read up on it a bit. I think king_kilr has though?
|
# ? Jun 3, 2010 15:33 |
|
I've never used it, but mingus is very much designed for developers, not being an end-user solution like wordpress.
|
# ? Jun 3, 2010 15:39 |
|
bitprophet posted:In its author's defense, the point of Mingus is to embrace the Django "reusable apps" philosophy. It's not that they're plugins to some core app, it's that the core app is simply a tiny bit of glue to hold all of the individual components together. You're pretty much correct - mingus is a pile of reusable apps under one banner, it doesn't implement a lot on it's own. I tend to use it piecemeal as I need for other applications. If I didn't have a ton of wordpress history, I'd be over on mingus right now personally.
|
# ? Jun 3, 2010 15:48 |
|
Does anyone have insight on keeping their Django code readable and testable? I read through Clean Code a couple of months back and have been trying to keep from letting my code get bloated and too multi-purposed, but it's not readily apparent what the best way to do that is in Django. I've started to define functions within my view functions to better separate layers of abstraction while keeping everything logically grouped together as a single unit, but I can't figure out how to use those from outside of the function, which means I can't write tests for them. Is the only way to just have a whole bunch of functions in the same namespace as your view function? Maybe define each view and associated functions within a discrete Python file? It seems like it'd be easier if every view was a class instead of a function.
|
# ? Jun 3, 2010 18:13 |
|
Sock on a Fish posted:It seems like it'd be easier if every view was a class instead of a function. So write class-based views? http://lmgtfy.com/?q=class-based+views+django
|
# ? Jun 3, 2010 18:48 |
|
MonkeyMaker posted:So write class-based views? http://lmgtfy.com/?q=class-based+views+django Is that what most people do? It doesn't have to be class-based, and honestly reading through those results class-based views look like a kludgy hack that could possibly be broken in later Django releases. edit: I'm thinking it might make more sense to make a views folder, and then for each view or set of closely related views a separate file. Sock on a Fish fucked around with this message at 21:08 on Jun 3, 2010 |
# ? Jun 3, 2010 20:48 |
|
the way i usually do it is like this:code:
|
# ? Jun 3, 2010 21:47 |
|
fixed, didnt use the correct decorator
LuckySevens fucked around with this message at 06:47 on Jun 4, 2010 |
# ? Jun 4, 2010 01:22 |
|
|
# ? May 15, 2024 02:07 |
|
I have an asinine template question that I can't figure out. I have a list of objects and I want to put the 'name' field of each, quoted, into a comma-delimited list. For example, if I have 3 stooges objects, I'd want the output: 'larry','moe','curly' Well, if I just had a list of strings instead of objects, I'd do: '{{string_list|join:"','"}}' But they're objects, so I use a for loop, as in: {% for obj in obj_list %}'{{obj.name}}',{%endfor%} That's good, except it leaves a trailing comma. I can crudely fix that, though: {% for obj in obj_list %}'{{obj.name}}'{%if not forloop.last%},{%endif%}{%endfor%} That seems excessively verbose for such a simple operation. Isn't there a better way?
|
# ? Jun 8, 2010 20:59 |