|
After .96 all html gets escaped, you need to disable auto-escaping. See here.
|
# ¿ Mar 11, 2008 22:16 |
|
|
# ¿ Apr 29, 2024 18:07 |
|
Try switching the 0 and 1 to true and false, maybe it forgets to do a type check before turning it into a string. Not sure if SQLite shits itself when you try to set a boolean field to 0 or 1. also what the christ self._aligns.keys().index(chunks[14]) is just self._align[chunks[14]]. deimos fucked around with this message at 21:45 on Apr 19, 2008 |
# ¿ Apr 19, 2008 21:42 |
|
ImJasonH posted:Which 0 and 1s? The only boolean field I have is already set with True and False. Dict key order is not guaranteed between implementations so you might want to rethink that strategem, make it into a multi-dimensional list. There's no need to turn this data into a number when a 3 character string will do, if you want to normalize normalize right but if you're gonna keep your data denormalized at least do so in a legible manner. I jumped to conclusions with the 0/1 thing. Try making the fields of a less restrictive type and see (ie. PositiveInteger instead of PositiveSmallInteger) it might be a bug in the backend. Your code somewhat stinks of SAVAGELY OPTIMIZED overtones. deimos fucked around with this message at 23:52 on Apr 19, 2008 |
# ¿ Apr 19, 2008 23:45 |
|
ImJasonH posted:You're probably right, I could probably save myself a lot of trouble by just storing strings in the database instead of ints. In fact, yeah, I'm going to tweak this some and simplify. I am not against storing ints where ints are due, but making them small or large really isn't saving you a lot. Still I'd love to know if it's some sort of backend issue with django so that a proper ticket can be opened.
|
# ¿ Apr 20, 2008 02:33 |
|
jarito posted:Sounds great. That should tide me over until the schema gets a little more definite. Got another stupid admin question. I have this in my models.py: generally speaking you don't want nulls in tables, it does funky stuff with some queries and generally acts weird depending on implementation. As to your problem, you also need blank=True. blank controls Admin.
|
# ¿ Apr 23, 2008 02:08 |
|
king_kilr posted:Not for much longer! On This Week in Django(great podcast), Malcom Tredinick(core commiter), said queryset-refactor will be getting merged sometime this week/next week, that branch fixes tons of SQL construction issues(including NULLS, joins, and about a billion other things). Ohh lordy lordy, this is excellent news.
|
# ¿ Apr 24, 2008 08:23 |
|
king_kilr posted:And queryset-refactor just hit trunk: http://code.djangoproject.com/changeset/7477 YAY! Quite possibly the best merge since the magic removal branch hit trunk.
|
# ¿ Apr 27, 2008 07:05 |
|
Bonus posted:code:
|
# ¿ May 7, 2008 03:58 |
|
Wulfeh posted:
Gah, this is a pet peeve of mine, it's a bit wasteful and IMO makes it harder to read when you have a single method that does both: self.cleaned_data.get('bool_field', False) works fine to replace both of those.
|
# ¿ May 15, 2008 03:40 |
|
Sock on a Fish posted:I've Googled around, and can't find an answer -- is there any significant performance boost from using a SmallIntegerField in my models instead of an IntegerField? One of my models is going to have about 100 attributes, only a handful of which are going to be negative or possibly exceed 65,535. However, I'd rather not make my model less flexible unless I'm going to get something for it. Performance? none. The advantage comes when you have millions (or even billions) and it nets you a slight storage improvement.
|
# ¿ Jun 1, 2008 04:40 |
|
make sure you're using .97 (SVN) otherwise Admin won't work right with unicode.
|
# ¿ Jun 30, 2008 22:35 |
|
StickBoy posted:TypeError at /admin/main/name/4/ Are you using postgreSQL by any chance?
|
# ¿ Jul 4, 2008 17:03 |
|
Does anyone have any good resources for running django on CentOS under WSGI? I am having trouble getting it to work.
|
# ¿ Aug 12, 2008 06:01 |
|
Space Kimchi posted:I managed to get apache/modpython working on CentOS but I'm starting to regret it a little as it likes to do things like cache error messages and never ever let them go (although restarting apache seems to clear things up). I can't find any information on where the cache is or how it works or how to tweak or disable it, it's kind of frustrating It's not "not letting them go" each apache child has it's mod_python which has it's corresponding copy of the source running, you have to apache2ctl force-reload (pretty sure force-reload works, but might actually need a restart). This is why if you make a site-breaking mistake it can take several refreshes to reflect it on Apache.
|
# ¿ Aug 13, 2008 13:10 |
|
Git posted:Sounds like you guys need to play with Apache's MaxRequestsPerChild option. I'm pretty sure the Django docs recommend giving it a value of 1 for development so code changes are reflected instantly. I don't even use apache for development. I use ./manage.py runserver <ip>:8000 when testing the mod_python config I just /etc/init.d/apache2 restart on the test install if I made a mistake then pushed live.
|
# ¿ Aug 13, 2008 21:29 |
|
king_kilr posted:new docs stuff just hit django, you can check out the hotness at http://docs.djangoproject.com/ I can't say I like this presentation better than the other. The old version was a bit clearer to me. Took me a while to even begin looking for the templates reference. (And there are like 5 links for templates) More gripes: Still no official signals documentation. Still no clear "views" docs other than the stuff intermixed in the tutorial. Still no middleware dev docs. I do like that it has breadcrumbs now and that the template docs are slightly more organized. deimos fucked around with this message at 09:54 on Aug 24, 2008 |
# ¿ Aug 24, 2008 09:50 |
|
bitprophet posted:There are clear "views" docs, the deal is that views are just Python functions...ones that take in requests and return responses, and thus the request/response docs are what you actually want. While I agree that the "views" docs are the request/response docs, it's not as easy for a newbie, can't just tell them "look at the request/response docs". With regards to the middleware docs: So that's where they went. I knew they were there before, now it's 3 clicks in with no reference to them within the front page. Usability overall of this iteration of the docs is... meh.
|
# ¿ Aug 24, 2008 17:33 |
|
I love django. I was asked to make a CSV available of data for a date. Took less than 20 lines of code, illustrated here so that if anyone wants to use it they can (and if they can come up with a better way of doing the info_dicts they can tell me, I feel it's ugly):code:
code:
|
# ¿ Aug 25, 2008 19:12 |
|
Milde posted:I don't think it handles what he's talking about by default, but he could use a custom dialect/writer like this: http://www.djangosnippets.org/snippets/993/ Nice link. And yeah the default CSV sucks at utf-8, I got tired of hacking it on a previous project so I went for the common case since everyone that's gonna use the app is gonna use it with excel. It was hacky but ffffff that. Also technically what I would need to write is a custom template filter and/or loader if I wanted to still use generic views, which was part of the point of this exercise.
|
# ¿ Aug 26, 2008 14:42 |
|
FINALLY got django working with MS SQL Server from a CentOS host. Recipe: code:
code:
code:
code:
code:
Adapted to the names above: code:
django-pyodbc - This site is almost empty of content. pyodbc - Has documentation of all the wrong things.
|
# ¿ Aug 26, 2008 18:27 |
|
The Real Ambassador posted:I dare you to get blob fields to work. One more thing to test. I've been running through django's test suite trying to fix stuff. bitprophet posted:It's not just the admin -- if you're still using oldforms at all, that's out the window now (but good riddance!). Hopefully not, I think regular newforms hit trunk like a year+ ago, and it's just newforms-admin that hit more recently. It's all a blur at this point, I've seen so many big changes to the codebase I can't keep it straight queryset-refactor bit me in the rear end even though I thought it was gonna be transparent.
|
# ¿ Aug 28, 2008 05:26 |
|
Senso posted:I know that but as you can see, I didn't take chances. PythonPath is defined in the VirtualHost Apache definition but I also defined it in bash, just to make sure. Sticky bit strikes again!
|
# ¿ Aug 29, 2008 04:20 |
|
NadaTooma posted:I'm about to start a new project, and trying to decide if I should use the built-in authentication system vs. rolling my own. I want two different account types: One for adults (requiring e-mail validation), and one for kids (no e-mail required), where each child's account is tied to one or more parent accounts, so that a parent can change manage their son or daughter's setup. This would imply a many-to-many relationship in the original Django "User" table, and I'm not sure it's designed for that. If I roll my own, I'm actually considering making it two tables (one for each account type), just to keep the DB design simpler. The built-in administrative pages, while awesome, aren't an issue here, because I'll be the only person using them in this case. You could inherit User into an AdultUser and ChildUser model and use them that way.
|
# ¿ Sep 8, 2008 16:42 |
|
While I dislike the mascot choice (a pink pony?) this is a neat representation.mwarkentin posted:You know the pink "magical pony" thing is a joke, right? It's a djangocon thing. deimos fucked around with this message at 23:05 on Sep 15, 2008 |
# ¿ Sep 15, 2008 22:14 |
|
dimebag dinkman posted:The Django docs make a big deal out of the fact that you shouldn't serve static files through Django. That makes sense, but what if I want to only allow the download of a large static file for people authenticated and in a certain group etc.? Is there actually any satisfactory way of having Django handle a request initially, and then have it pass control over the fastest method available to send a static file? (I'm using lighttpd + FastCGI, currently.) http://trac.lighttpd.net/trac/wiki/Docs:ModSecDownload http://wiki.codemongers.com/NginxXSendfile Basically you change the headers and shazzam proxied download. (actually lighty's is a bit more complicated but who cares, use nginx)
|
# ¿ Sep 30, 2008 02:07 |
|
duck monster posted:Mod python gently caress mod_python TBH. Seriously, don't use it.
|
# ¿ Sep 30, 2008 02:33 |
|
Milde posted:deimos obnoxiously alluded to it Eh? how was I obnoxious? I gave him relevant links and gave a very concise explanation of how the technique works (for nginx), neither link lacked explanations as to how they worked so there was no need to write . bitprophet posted:To be fair, use of WSGI, with any server (i.e. mod_wsgi with Apache, or whatever the nginx equiv is) is becoming more popular lately, and a decent number of people also use FCGI. WSGI is the best thing for hosting django apps. The only problem is that the django devs say it's the best way to host django apps (just go to #django or the django-users mailing list), but it seems they don't want to put it on the docs because not all web servers have WSGI available to them. There are very few reasons to use mod_python, and none of them really make sense to me, because most of them involve using parts of Apache that are normally not exposed to web apps. I would personally forego apache/django and switch to twisted/nevow for that degree of control, or, I would separate the things that require you to control apache into their own applications. But I can see a very small subset of projects needing it.
|
# ¿ Sep 30, 2008 15:00 |
|
bitprophet posted:
If you have lighty or nginx in front of django (which you should) you can still allow them to serve the graphic by using the header trickery I posted a while back for sending FS files.
|
# ¿ Oct 12, 2008 01:22 |
|
hitze posted:
try code:
|
# ¿ Nov 16, 2008 00:45 |
|
bitprophet posted:Thanks for actually verbalizing my post. I didn't have time to write a full answer when I posted that.
|
# ¿ Nov 16, 2008 06:14 |
|
hitze posted:Well after rereading the docs for models and page 3 of the tutorial (for the upteenth time) I came up with this: Gah, go back and re-read the tutorial and documentation, specifically this page. 1. Why do you insist on setting the albums and songs to a variable. 2. Why are you using get() when stuff might return more than one value? You use get to get a single instance. For #1 you do not need to be declaring all those variables on your view. Try this as your view: code:
code:
quote:
That's because Album indeed does not have an album_set; artist has an album_set and each album in the album_set has a song_set. deimos fucked around with this message at 17:31 on Nov 16, 2008 |
# ¿ Nov 16, 2008 17:28 |
|
THEY CHANGED THE DOCS INDEX PAGE AGAIN You're gonna have to create a custom field (inherit from forms.ModelChoiceField) or use a form validator on whichever form you use to create the categories. All you have to do is check that the id field of the object doesn't match the foreign key id.
|
# ¿ Nov 23, 2008 04:46 |
|
The Red Baron posted:My seemingly decently elegant django.contrib.comments signal-based reCAPTCHA implementation, which I posted a link to earlier in this thread, suddenly got some serious egg on its face when someone pointed out that the comment framework's signal handling only allows for returning a HTTP 40x error when a signal handler returns false rather than redisplaying the form with a message. As a result, people mistyping the captcha get some seriously crappy feedback (or lack thereof). For reference, here's the link. You could monkeypatch CommentForm.__new__ to apply a decorator on the security_errors function to check for recaptcha errors. deimos fucked around with this message at 18:16 on Dec 10, 2008 |
# ¿ Dec 10, 2008 18:13 |
|
Washington Times just released some pretty awesome django projects: http://opensource.washingtontimes.com/blog/post/coordt/2009/02/washington-times-releases-open-source-projects/ edit: Forgot to mention that I started playing with django-projectmgr and it is pure awesome. deimos fucked around with this message at 02:05 on Feb 20, 2009 |
# ¿ Feb 20, 2009 01:24 |
|
As a sidenote, what's the state of django on Windows? I haven't tried it at all. I need to connect to SQL Server and last I checked the only reliable way was running django on Windows through Apache and mod_python.
|
# ¿ Feb 20, 2009 06:30 |
|
Crazak P posted:Awesome, thanks man. I knew I had to use divisbleby somewhere, but I was thinking more along the lines of declaring a variable, which I don't think you can using the template language. The loop variables are really great, make sure you learn them because they're very useful here.
|
# ¿ Feb 21, 2009 05:18 |
|
bitprophet posted:I saw the feature list for that and basically creamed myself, it's got a LOT of ideas I was hoping to put into a tiny fledgling Django app I have going in the same vein. Plan to check out the source sometime soon. The source is gorgeous. It's really clean code and from what I have browsed so far, I've already learned a couple of new things. You actually need to dive into the code to see some of the really neat stuff it does like notifications using django-notification. Ohh and MPTT is my new most favorite thing ever. deimos fucked around with this message at 05:45 on Feb 21, 2009 |
# ¿ Feb 21, 2009 05:30 |
|
king_kilr posted:Somehow I imagine m0nk3yz jumping straight up to Marty's book within a week. I picked up Marty's book and I really really like his explanations of django's metaclass voodoo. It never really clicked until I read the chapters explaining it. I mean I sort of got it but it wasn't all there. That alone made it worth the price of admission. Speaking of metaclass voodoo, now that I actually understand it 100% I am gonna try replacing django's sessions with a redis backend. Should aleviate the DB hammering when using sessions (this is inspired by Cal Henderson's rant about hitting the DB for a session on almost every view). As an aside, redis is sex. deimos fucked around with this message at 03:10 on Mar 18, 2009 |
# ¿ Mar 18, 2009 03:05 |
|
ToxicFrog posted:I also have a question about mod_python, in case anyone here can answer this: is there a way to turn off cacheing or flush the cache, assuming I don't have root (and thus can't restart apache, which seems to be the 'official' way to do this)? The Django test server is a godsend, because whenever we test it on the deployment server, it's pretty much guaranteed to cache an incomplete or nonworking version of the site and then we have to wait for the cache to expire. The quick answer: PythonAutoReload On may or may not work. The correct answer: don't use mod_python, use mod_wsgi. ToxicFrog posted:The way I'm currently handling this is that each of these is its own model; Sponsor, Protocol, and PurposeList are each a Model in their own right, with a ForeignKey dependency on RequestForm. The view uses this to retrieve them, splices them into the RequestForm object, and proceeds from there. I am really not understanding your models, maybe because you keep calling them things that generally conflict with what models are. A model is a model and there should not be List or Form in their classnames IMHO. A Sponsor model is a representation of a sponsor and a Purpose and not a PurposeList should be a representation of a purpose. That having been said, django does provide you with ModelForms which do all the form dirty work for you. Might want to start there. deimos fucked around with this message at 05:04 on Mar 18, 2009 |
# ¿ Mar 18, 2009 04:57 |
|
|
# ¿ Apr 29, 2024 18:07 |
|
ATLbeer posted:MySQL doesn't support hour in it's datetime implementation. MySQL has HOUR() which when applied to a datetime value gives you the hour.
|
# ¿ Apr 20, 2009 22:27 |