|
Git posted:That's one hell of an OP. I'll kick off the stupid questions: Yeah mostly you'll use render_to_response, but what you can also do is return 404 errors or 403 redirects. A nice thing to take advantage of is that you can return other views, just with different parameters, which can be very useful sometimes.
|
# ¿ Mar 6, 2008 00:17 |
|
|
# ¿ Apr 28, 2024 17:48 |
|
Putting them in separate folders decouples your application from your templates a bit more. For instance, you can release a new version of your application and people who are using it just replace the application folder and the templates stay intact if they are using their own or something. Have you tried explicitly telling Django where the templates are located by adding an entry to TEMPLATE_DIRS in settings.py?
|
# ¿ Mar 7, 2008 15:49 |
|
If you mean what I think you mean then yeah, because querysets are lazy. They are only evaluated when evaluating them is absolutely necessary (see QuerySets are lazy) So if you have code:
hey mom its 420 fucked around with this message at 16:11 on Mar 7, 2008 |
# ¿ Mar 7, 2008 16:09 |
|
How about going with a VPS? I hear slicehost are really good and also I think legalcondom is offering good and cheap VPS hosting for gunes.
|
# ¿ Mar 7, 2008 20:46 |
|
ashgromnies posted:I think I'm doing something wrong... I just started with Django and got everything set up and got the administrative interface working. What does your directory and file layout look like? Because adding just app_name to INSTALLED_APPS wihtout prefixing it with the site name should work, at least it works for me.
|
# ¿ Mar 11, 2008 09:08 |
|
Sure, you can do all of that, take a look at this part of the documentation, it explains how it works quite nicely.
|
# ¿ Mar 11, 2008 09:30 |
|
ashgromnies posted:Why not? I want the question mark to be optional. In most regular expression engines(including Python's), the question mark means to match the preceding character zero or one times. That's technically correct but I've found that it works best if you don't put the question mark after the slash and then Django will automatically append a slash if you haven't explicitly told Django not to (i.e. don't set APPEND_SLASH = False in settings.py) edit: ugh beaten. f u bitprophet
|
# ¿ Mar 12, 2008 15:28 |
|
Putting a Meta inner class inside a model and assigning unique_together fields effectively achieves the same thing as composite primary keys. They're not composite primary keys in the DB, but there's an index over both of them, so effectively it's the same.
|
# ¿ Mar 13, 2008 17:19 |
|
FrontLine posted:Ideas? code:
|
# ¿ Mar 18, 2008 09:32 |
|
Oh, well then yeah, just import the stuff you need from the script and that's it. Unless I'm misunderstanding your problem somehow.
|
# ¿ Mar 18, 2008 09:52 |
|
Yeah, sure. At the beginning of your views.py, just have an import statement that imports your script, example (making stuff up here):code:
code:
|
# ¿ Mar 18, 2008 11:39 |
|
On our Django project, we're using jQuery and stuff works out just fine. You make views that serve the data that's requested asynchronously and then just write the jQuery to call them. Like king_kilr said, you can also use Django's serialization features in the views that are served up asynchronously. I like either serializing stuff into JSON and then reading it with the javascript or just directly sending html.
|
# ¿ Mar 22, 2008 21:44 |
|
Yeah, just use the SVN version, I don't recall anything getting borked when upgrading and if they change something (like when they changed the maxlength model field option to max_length), they usually keep the old behavior and issue a deprecation warning upon usage. Also, Django has a very good extension to the unittest module and it's pretty easy to make some basic test coverage for your code so you know immediately if something major gets broken.
|
# ¿ Mar 29, 2008 18:16 |
|
What I usually use when I want the database nuked and then resynced is a script that I run. I usually have an sqlite database on my development machine. Here's what it usually containscode:
What I'm having the most problems with is keeping test data in the face of changing models. Say I have some tests and some test fixtures which the tests load when they begin running so they have something to operate on. Now if I change the models and run the tests, all of a sudden the test data can't be loaded in by the tests because the models are different than what the test fixture was made for. I usually have a test fixture in JSON. So anyone know a good way around that?
|
# ¿ May 6, 2008 22:57 |
|
Yes but you see, this way I get to use the awesomely cool yes program.
|
# ¿ May 7, 2008 12:02 |
|
deimos posted:
Just another response to this: I remember trying sqlreset before but couldn't remember why I'm not using that command. Tried it again today. The thing with sqlreset is that you have to specify all the app names that you want to reset. That's a bit of a hassle when your project is decoupled into a bunch of apps. So I guess I'm still sticking with my yes "no" script
|
# ¿ May 9, 2008 18:29 |
|
Use a double underscore to follow foreign key relationships when filtering, selecting, etc.code:
code:
|
# ¿ May 12, 2008 16:59 |
|
Wouldn't you want to and_ them together in that case?
|
# ¿ May 24, 2008 19:09 |
|
Yeah, that's cause reduce will fail if it gets an empty sequence with no initial value. In your case that happens when query == ''. I think you could pass a third argument, Q() to that reduce to avoid getting that error on an empty string, but I'm not really sure. However, I think anding the Q objects together won't work like expected because that just checks that the field contains all those letters. It doesn't check their order or how many of them there are. I think you might be able to achieve what you want by using the iregex field lookup and specify the regex so that it ignores the characters you want.
|
# ¿ May 24, 2008 19:43 |
|
Yeah, ummm, do you mean like version control? Like mercurial, git, svn, etc.
|
# ¿ May 30, 2008 23:31 |
|
Ooh, you mean like revisions are stored in wiki pages, kind of like that? Ah, I don't know, but it seems like the cool triple post nailed it. lol
|
# ¿ May 30, 2008 23:36 |
|
Because then you don't get to use some the nifty features that contrib.auth offers, like messages and getting the user directly from request. The proper way to extend the User model is described here.
|
# ¿ May 31, 2008 22:45 |
|
Yeah saw this today, looks pretty cool. I just hope that after 1.0 they'd release versions more often. I might even contribute a bit over the summer, try fixing some bugs, etc.
|
# ¿ Jun 13, 2008 00:01 |
|
What does the method look like, exactly? Also make sure you are using unicode strings when returning. So don't return 'something', instead, return u'something'. The u in front of the quote means it's a unicode string.
|
# ¿ Jun 30, 2008 22:10 |
|
Yes, definitely! Get the SVN release, 0.96 is pretty much archaic. I bet upgrading to the latest version will fix that for you or I'll eat a spider. Don't toxx me on that though.
|
# ¿ Jun 30, 2008 22:41 |
|
checkeredshawn posted:It's your lucky day! Unless you enjoy eating spiders, that is. I checked out the latest version and now I've got 0.97-pre-SVN-unknown. It's better to make a symbolic link from the site-packages directory because then uninstalling Django is as easy as removing the symbolic link and you can update your copy of Django from the trunk without being a super user, you just go into the trunk directory and do svn update.
|
# ¿ Jun 30, 2008 23:24 |
|
No, that's an old rear end version, no one should really be using it. Use the SVN version. To do that just checkout the latest changeset by doing svn co http://code.djangoproject.com/svn/django/trunk/ and then installing it.
|
# ¿ Jul 5, 2008 22:37 |
|
1.0 is supposed to come out on September the 2nd. Read more about the schedule here
|
# ¿ Jul 6, 2008 00:35 |
|
Use the template inheritance functionality along with the auth context manager. First off, in your settings.py, check that django.core.context_processors.auth is in the variable TEMPLATE_CONTEXT_PROCESSORS. Then in every view, give it a request context like this.code:
Once you've done that, you can do stuff like code:
hey mom its 420 fucked around with this message at 18:17 on Jul 8, 2008 |
# ¿ Jul 8, 2008 18:13 |
|
Yeah, you usually do that by overwriting the save method or by using signals. The way to overwrite the save method is pretty straightforward.code:
hey mom its 420 fucked around with this message at 22:31 on Jul 9, 2008 |
# ¿ Jul 9, 2008 22:27 |
|
Hehe, no problem. If you have a ModelForm, you can pass a keyword argument of commit=false when you call its save method.code:
|
# ¿ Jul 28, 2008 18:17 |
|
Give this a read: http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02 You don't make models part of the admin interface by putting an inner class of Admin in the models anymore.
|
# ¿ Oct 11, 2008 18:45 |
|
Congrats man! When I get some cash, I'll pick this up!
|
# ¿ Oct 31, 2008 00:11 |
|
You can override the manager's __init__ method and give it an extra argument and then save that argument as an instance variable and then call the superclass __init__. That way you can do something like characters.mine(request.user).all()
|
# ¿ Nov 2, 2008 13:36 |
|
Explicitly referring to your project name from your apps is generally discouraged because it reduces the portability of your apps. Even if your apps aren't meant to be portable, I still wouldn't use it.
|
# ¿ Sep 4, 2011 10:16 |
|
|
# ¿ Apr 28, 2024 17:48 |
|
Hey y'all, what do your fabric scripts for deploying look like? This is mine, and it seems awfully simple, is there something that I'm missing or is this OK as far as deployment goes? We still don't have tests so there's no testing, but I'll add those as well.code:
|
# ¿ Feb 21, 2012 02:16 |