|
Going to show my ignorance here but whatever. I noticed when Django is querying the auth database, it selects EVERYTHING including the users password:code:
|
# ? Feb 3, 2011 12:26 |
|
|
# ? May 31, 2024 06:03 |
|
Hanpan posted:Going to show my ignorance here but whatever. I noticed when Django is querying the auth database, it selects EVERYTHING including the users password: The password is hashed and the database string is in a format like this hashtype$salt$hash. So an example would be sha1$a1976$a36cc8cbf81742a8fb52e221aaeab48ed7f58ab4. Hashes are not reversible (ignoring rainbow tables, which in this case would be useless unless you had a rainbow table that was precomputed for each salt, which is different for each user).
|
# ? Feb 3, 2011 13:13 |
|
Ahh yes, I forgot about all that crazy salting. Another question which came up today; I have a Media Manager app which I am attaching media to 'content' using the following table: code:
I want to keep the Entry model as abstract as possible, so overwriting the delete method to remove any media attachments seems a if a lame solution. Does anyone have any bright ideas as to how I could remove those redundant records when an Entry object is deleted?
|
# ? Feb 3, 2011 15:35 |
|
Hanpan posted:Ahh yes, I forgot about all that crazy salting. If you had the ForeignKey on Entry instead of MediaAttachment it would do that by default. If you want to continue the way you are doing it, you could use a signal instead.
|
# ? Feb 3, 2011 15:41 |
|
Profane Obituary! posted:If you had the ForeignKey on Entry instead of MediaAttachment it would do that by default. A Foreign Key won't work because you can attach more than one piece of Media.. I like the idea of using signals. Do you happen to know if there is a way to listen for a delete signal on ALL models? That way I can keep things nice and dynamic on my Media model... whenever some 'content' is deleted, check it for attachments. Edit: I figured this out, for anyone who wants to know, you don't have to define the sender of a post delete signal. Probably a really slow method but it works well enough: code:
code:
\/\/\/\/\/\/\/\/\/\/\/\/\/\/ Hanpan fucked around with this message at 17:29 on Feb 3, 2011 |
# ? Feb 3, 2011 15:54 |
|
The other option is to leave it how it was, but make a cronjob that selects all the Media attachments without an Entry, and then delete them.
|
# ? Feb 3, 2011 17:21 |
|
Hanpan posted:Ahh yes, I forgot about all that crazy salting. If you put a GenericRelation on the Entry object then it will get deleted automatically: http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#reverse-generic-relations
|
# ? Feb 3, 2011 21:49 |
|
Sorry to poo poo up this thread with my dumb rear end questions, I hope someone can help me out. I am using the contenttype framework to create a "media attachment" app which allows me to 'attach' media (images) to objects (pretty much the same as the one I posted above). It's fairly straight forward and works quite well. I want to expand on it slightly and define each attachment further... if you imagine a blog post which has 4 images attached to it, but one of those images is a 'header image', I want to be able to differentiate that attachment. I have done this by adding another column to my attachment table: code:
code:
Is there a better way in which I could do this or should I stop worrying and deal with it?
|
# ? Feb 7, 2011 17:41 |
|
I haven't used them myself, and I'm not really sure how good this would be, but how about using proxy models that hardcode the taxonomy value? We only just upgraded from 1.0.4 so I'm not familiar with all of these newer features. Or maybe have an "attachment_type" field with predefined choices, making it a drop-down option in forms. raymond fucked around with this message at 00:52 on Feb 8, 2011 |
# ? Feb 8, 2011 00:48 |
|
Does anyone know the correct syntax for putting data into a GeoDjango pointField Heres my model: code:
If I put a Point(lng,lat) in, I get: TypeError: cannot set ContactCard GeometryProxy with value of type: <class 'geopy.point.Point'> If I try a 'POINT(23.23345345,1.234234234)' type string, it comes back wondering what I'm smoking. The GeoDjango documentation is atrocious e: Just worked it out. Namespace clash between Geopy + GeoDjango. Ugh....
|
# ? Feb 14, 2011 10:59 |
|
If you think there's a problem with the docs, please please please file bugs on them, including just needing more details.
|
# ? Feb 14, 2011 17:02 |
|
king_kilr posted:If you think there's a problem with the docs, please please please file bugs on them, including just needing more details. Never worked for Twisted I love the framework, I really do. But when your documentation says one thing, your Epydoc says another and the code does something else entirely, it's a problem.
|
# ? Feb 14, 2011 19:16 |
|
Captain Capacitor posted:Never worked for Twisted Yes it is. We take our documentation seriously.
|
# ? Feb 15, 2011 03:02 |
|
king_kilr posted:If you think there's a problem with the docs, please please please file bugs on them, including just needing more details. What am I going to say? Bug: Your documentation is poo poo. Stop being poo poo. ...then deal with a bunch of manchild spergelords who are angry because the bug was already filed a year ago and marked "Wontfix"?? Yeah I'm 100% over open source bug trackers, sorry dude. Nothing, absolutely nothing, brings out the aspergic nature of the geek like bug-trackers can do. e: Seriously though, Django's docs are generally great. But the geodjango docs have some giant holes around field definitions, and what those field types mean and how to access them. Maybe those details ARE in there, but damned if I can find them, cos they aint in the logical place. Its important to remember that whilst most of us approach django from either a web developer or coders knowledge of things, we are approaching GIS from absolute newbie-cluelessness. Lots of hand holding is needed by docs here and NO prior knowledge of GIS ought be assumed. duck monster fucked around with this message at 03:12 on Feb 15, 2011 |
# ? Feb 15, 2011 03:08 |
|
duck monster posted:What am I going to say? Ok spergelord, why don't you just say "documentation is unclear because of reason X, Y, Z, can you please provide more detail!" From reading a single post I'm willing to bet that the responses you've gotten have to do with your manchild bug reports which consist of nothing but "your documentation is poo poo." epswing fucked around with this message at 06:04 on Feb 15, 2011 |
# ? Feb 15, 2011 06:02 |
|
duck monster posted:Seriously though, Django's docs are generally great. But the geodjango docs have some giant holes around field definitions, and what those field types mean and how to access them. Maybe those details ARE in there, but damned if I can find them, cos they aint in the logical place. In short, please do submit a ticket. It's not hard, and I've rarely (never?) seen any childishness in the tickets. I imagine that's reserved for the mailing lists king_kilr posted:Yes it is. We take our documentation seriously.
|
# ? Feb 15, 2011 19:35 |
|
Hopefully some kind soul can check this code over for me. I want to create a thumbnail of an uploaded image. Annoyingly, since the file doesn't exist on the server until after the save method is called, I can't see any around doing this using the post_save signal. I am aware you can generate images by storing the image in memory before it's saved, but I don't really want to rape my servers resources every time I upload an image. Here is the code I am using: code:
I'm going to extend this class further to allow for different kinds of media, incase you are wondering why I am using a FileField for the file attribute. Obviously I won't create thumbnails for anything other than images. It works ok, but the reliance on the post_save signal worries me a bit as I only ever want to create a thumbnail the first time the instance is saved, and never again.. I am hoping the 'created' kwarg will prevent that? I'm also hitting the database twice, once when the model is saved and again once the thumbnail has been generated. Considering I may also want to post process the uploaded image (resizing etc), that is going to take it up to 3 queries. I'm hopeful there is a way to do all that post processing before anything is actually saved to the database? Any insights would be appreciated, I like to keep my code as pythonic as possible
|
# ? Feb 16, 2011 12:21 |
|
I'd just use sorl, this is a solved problem. Unless you are wanting to do something special that sorl can't do? http://thumbnail.sorl.net/
|
# ? Feb 16, 2011 13:27 |
|
Profane Obituary! posted:I'd just use sorl, this is a solved problem. Unless you are wanting to do something special that sorl can't do? Yea, a lot of people seem to suggest using sorl. I have nothing against it, but in this instance, I really want to do it myself because not only will I learn how but I also don't need half of the functionality sorl offers I have a lot more control this way too, as I have also created some custom fields and admin widgets which integrate nicely with my media module.
|
# ? Feb 16, 2011 13:40 |
|
In that case, why not look at sorl to see how it does it? I would assume with the number of people using sorl, it's method probably isn't terrible. Though i don't really see a problem using the post_save hook. The other option is to make m.thumbnail a method instead of a real field, and generate it the first time the image is requested.
|
# ? Feb 16, 2011 14:55 |
|
Is there a reason you didcode:
code:
|
# ? Feb 16, 2011 15:30 |
|
Because it is a tuple.code:
code:
Hanpan fucked around with this message at 11:09 on Feb 17, 2011 |
# ? Feb 16, 2011 17:38 |
|
Hanpan posted:Because it is a tuple. code:
code:
|
# ? Feb 16, 2011 21:16 |
|
Is there something like htmltidy that works well for markup with template tags? I've got a ton of lovely templates that I would like to prettify, but htmltidy joins all lines of my Django template directives.
|
# ? Feb 18, 2011 21:59 |
|
First off, I haven't read the whole thread, so I'm sorry if these issues have already been addressed elsewhere in one form or another. Then again, I'm such a Django newbie (and Python newbie in general, really), that most people wouldn't be asking these questions in the first place. Also, I'm aware that there are Django-powered blogging applications out there and in some ways I'm trying to reinvent the wheel. Sure, my will be made of wood and rawhide in the time of alloys and carbon fiber, but sometimes one just needs to learn by doing.
|
# ? Feb 19, 2011 20:40 |
|
latexenthusiast posted:My solution at the moment feels a little fragile. Let's first assume that I have a function urlify that will transform the string "«Je parle le français (un peu)»" into "je-parle-le-francais-un-peu" (i.e. everything goes to lowercase, spaces are replaced with dashes, punctuation is dropped, accented characters go to ASCII-looking equivalents if available, otherwise are dropped)--basically, it makes strings URL-friendly. This is a common enough case that it's handled for you, using models.SlugField and the slugify templatetag (the latter of which is just a python function you can import. latexenthusiast posted:It kind of sucks, though, because I may want to change get_absolute_url at some point, and that would mean all the BlogPost objects need to be re-saved, so that sucks. (Is there a way I can do a mass re-save?) It's probably bad in some other ways, too. latexenthusiast posted:The former seems slightly more DRY to me, but at the expense of having one relatively complicated view function as opposed to bunch of little ones, so I think in that sense the latter approach is superior. Personally, I'd have different view functions for the distinct options in filtering/displaying data, if only because it makes it much easier to add in additional features to one view without having to worry about the rest of the logic. Class Based Views, when they land (1.3) will, I think, make this kind of grouping easier, however. Yay fucked around with this message at 21:04 on Feb 19, 2011 |
# ? Feb 19, 2011 20:55 |
|
Just to add, I find using the {% url %} template tag pretty useful as it means I don't have to use get_absolute_url and worry about keeping it updated.
|
# ? Feb 20, 2011 02:19 |
|
Yay posted:Personally, I'd have different view functions for the distinct options in filtering/displaying data, if only because it makes it much easier to add in additional features to one view without having to worry about the rest of the logic. Class Based Views, when they land (1.3) will, I think, make this kind of grouping easier, however. There's nothing stopping you from using class based views now either.
|
# ? Feb 20, 2011 03:11 |
|
What do you guys do about multilingual urls? I'd like to be able to translate my urls so that /en/woop/ can be translated into /da/whoop and hit the same view on the same site. I've found an app that tries to handle this problem transurlvania, but according to an open issue the app isnt threadsafe.
|
# ? Feb 20, 2011 19:45 |
|
I'm having an awful time getting django-piston working with apache/mod_wsgi on windows. I have literally 24 hours before go live so I can't exactly switch REST frameworks or off of windows. I had to edit piston.utils.Mimer.content_type to: code:
Now, anything I have that returns piston.utils.rc.ANYTHING it throughs a big dumb error. For example: return rc.CREATED will give me an Apache 500 error, not a django error: code:
code:
code:
edit: gently caress I hate piston so goddamned much. I'm going to replace it the second I can. Turns out it pistons streaming output clobbers the whole thing and I cannot raise HttpResponses because piston is trying to stream it, not return it. multigl fucked around with this message at 06:50 on Feb 22, 2011 |
# ? Feb 22, 2011 06:09 |
|
If I override a ModelForm's clean(self) method, I would typically call the parent's clean(self) method, right? What's weird is that I'm not calling the parent's clean(self) method, and validation on fields I'm not handling in my clean(self) still seems to be happening...
|
# ? Feb 26, 2011 21:38 |
|
That stuff isn't called by clean, it's called by full_clean (or maybe _full_clean).
|
# ? Feb 27, 2011 01:57 |
|
I need some advice of cultivating a testing suite. At work we have a fairly large django project, which has recently (over the past 2 months or so) gone from 0% coverage, to about 60% coverage. The problem is that the guys that are in charge of the QA process are, in my opinion, going about it entirely wrong. These guys come from java, where I guess mocking is a common strategy to creating tests. The problem is that I don't really think the mocking strategy is really best for the way django's testing framework is set up. For instance, we have a MockQuerySet object they we have to monkey patch in before using any models that moick out save() and a bunch of other stuff. We also have a subclassed TestCase class that does an unholy amount of stuff. Basicvally, each and every test is pretty much 50% mocking, then the other 50% is actual test code. The way inporting works in python (and the way django works makes it much worse) means that you have to pretty much mock out an object once each time it's imported if you want to completely mock it. So our test code gets really complex really fast. There is this bit of code I wrote which works by generating a random number, and then doing something with that random number. My test just iterated over that bit of code until I got the result I was looking for (i'm simplifying big time). When the QA tester saw my test, he rejected it, saying that all tests have to be deterministic, and that there is a 0.00237% change that the test will fail even though the code is right, so he made me mock out the call to random.randint(), which was waaaay harder than it sounds, because I had to restore that mock before random.randint() was called later on. It was a big mess in my opinion, but the people in charge seem to think this is the only way to go about it. I don't really have a lot experience with django testing, or testing in general for that matter. Is this a legitimate strategy for doing test? Literally, every single one of our tests has at least 10 or so lines of mock code at the begining. Is this typical? My gut reaction is that since the django tests documentation doesn't include any mocking tools, or even really mention mocking at all, that this mocking fetish we have is wrong. What do you all think?
|
# ? Feb 28, 2011 18:43 |
|
Since Django has reasonably recently been migrating away from doctests to proper unittests, there's a fairly comprehensive test suite included in the package which probably demonstrates a recommendable method of doing so. In my experience looking at them, an awful lot of the tests are small, or just bundles of assert tests. Not the monolithic things you're describing. IMO, tests should be as concise as possible, because if you can't write bug-free production code, why risk writing buggy tests? short and sweet means less opportunity to go wrong, usually.
|
# ? Feb 28, 2011 19:59 |
|
Are there any Django tutorials for creating a forum? I want to learn Django, but I need to apply it to something interesting and relevant. I know it can't be that different than a general CMS, but it'd probably make for the most productive investment of my time.
|
# ? Mar 6, 2011 17:05 |
|
ufarn posted:Are there any Django tutorials for creating a forum? I want to learn Django, but I need to apply it to something interesting and relevant. I don't know of any tutorials, but if you can design the data model for it, you can likely code the rest, since the queries and views will come naturally (view forum list, view topic list, view thread).
|
# ? Mar 6, 2011 21:32 |
|
Stabby McDamage posted:I don't know of any tutorials, but if you can design the data model for it, you can likely code the rest, since the queries and views will come naturally (view forum list, view topic list, view thread). (And I'm also so new to the framework that I don't know any of the basic apps there are, but maybe that's not pivotal when working in Django.)
|
# ? Mar 6, 2011 22:04 |
|
ufarn posted:I'm fairly confident about pulling it off like any other dynamic system. It's just that it'd be more of a DYI gig rather than following a guide and being more effective with my time and concentration. build a blog. everyone build a blog. ten million django blogs.
|
# ? Mar 7, 2011 04:41 |
|
multigl posted:build a blog. everyone build a blog. ten million django blogs.
|
# ? Mar 7, 2011 15:00 |
|
|
# ? May 31, 2024 06:03 |
|
ufarn posted:NO. I refuse to build a goddamn blog.
|
# ? Mar 7, 2011 20:44 |