|
I am trying to detect duplicate uploaded images. I have a method that generates a signature for each image that is uploaded and I want to verify it against all the other signatures I have collected. When is the best time to do this? I don't really think the model's .save() method is the right time, since that code would get called for every successive save, but images only get uploaded once. I'm also not really sure on how to deal with validation from the user's perspective. If anyone has any insight on that, I would love to hear it.
|
# ? Jul 29, 2009 03:20 |
|
|
# ? May 15, 2024 02:33 |
|
Use django.forms. It has everything you'll need. Start with the docs: http://docs.djangoproject.com/en/dev/#forms
|
# ? Jul 29, 2009 03:31 |
|
Security Announcement: http://code.djangoproject.com/changeset/11351 see successive commits for patches against 1.0.2 and .96.x. Releases will be forthcoming. Edit: Corresponding blog post: http://www.djangoproject.com/weblog/2009/jul/28/security/ 1.1 release do within hours. king_kilr fucked around with this message at 05:55 on Jul 29, 2009 |
# ? Jul 29, 2009 04:36 |
|
http://docs.djangoproject.com/en/dev/releases/1.1/
|
# ? Jul 29, 2009 17:55 |
|
MEAT TREAT posted:http://docs.djangoproject.com/en/dev/releases/1.1/ mmm... Proxy models look quite useful
|
# ? Jul 29, 2009 18:21 |
|
I've got a question about many-to-many relationships. In the following model:code:
|
# ? Jul 29, 2009 21:32 |
|
SlightlyMadman posted:I've got a question about many-to-many relationships. In the following model: How do you want the user associated to these models? Do you want the publication as a whole being attached to the user, or are individual pages of a publication written by different users? The first means putting User on Publication. The second means putting user on the Page model. After that, you have two options, you can either put Page as a M2M field on the Publication model, or you can put Publication as a Foreign Key on the Page Model.
|
# ? Jul 29, 2009 21:56 |
|
Actually, the link itself is unique to the user. A user generates a Link, which is a specific page, targeted at a specific publication. Think of a link more as an instance of a page, but for a specific user and publication. Let's say my page is "foo.html" and my publication is "MySite.com". There is already a many-to-many relationship between them, but further each user in my system gets their very own link for the combination of foo.html and MySite.com.
|
# ? Jul 29, 2009 22:32 |
|
Alright - bear with me, this is driving me up the wall. I'm working on my first django project of substance and I'm trying to set up my code in a way that doesn't annoy me too badly. I'm struggling with the way django seems to require the naming/location of the models. They seem to either have to reside at the top level of your app in models.py or in a subdirectory models/. Django seems bizarrely focused on having the string "models" involved and I can't figure out a way around it. I'm trying to locate the model for a given class inside said class and not have to have a second class exist solely to wrap up the model. I blame the last 2 years I've spent in java + hibernate for this... I'm not sure that makes sense, but what I'm trying for looks like this: code:
|
# ? Jul 31, 2009 19:07 |
|
This is how django wants you to do it:code:
|
# ? Jul 31, 2009 21:05 |
|
nbv4 posted:This is how django wants you to do it: I realize that's how django wants it done, but not how I want to do it. My deeply ingrained OO-tendencies and code organizations are in a fight with django!
|
# ? Jul 31, 2009 21:51 |
|
devilmouse posted:I realize that's how django wants it done, but not how I want to do it. Is the problem just that you want to put each class of your model in its own file, instead of putting them all in models.py? If you don't like the django/python way, then there's plenty of java application frameworks out there you're welcome to use instead. If you're going to use django though, you'd better do it the django way or it's going to hurt. I bet you capitalize your method names too, don't you? To make a horribly inappropriate analogy, think of it like taking it in the rear end. Sure you may be used to vaginal sex and want to follow the same procedures, but if you insist on not using lube it's going to hurt.
|
# ? Jul 31, 2009 22:00 |
|
SlightlyMadman posted:To make a horribly inappropriate analogy, think of it like taking it in the rear end. Sure you may be used to vaginal sex and want to follow the same procedures, but if you insist on not using lube it's going to hurt. An excellent analogy! It's mostly me fighting with a new language/framework and if it's the accepted way, I'll comply with it. My last real web coding was done with perl in CGI, so things are a bit different now! It's for work so I don't have the option of using anything else. I guess I'll just suck it up and learn the django way. Thanks for being blunt about it! It makes sense, I just didn't want to like it. For the record, no, in python/perl, I use all lower-case for function names, separated with underscores! I'm not some sort of heathen, gosh.
|
# ? Jul 31, 2009 22:10 |
|
http://www.youtube.com/watch?v=A-S0tqpPga4 you should watch this, devilmouse. Good explanation of the django philosophy and how it should effect your design.
|
# ? Aug 1, 2009 01:17 |
|
SlightlyMadman posted:If you're going to use django though, you'd better do it the django way or it's going to hurt. I bet you capitalize your method names too, don't you? Er, what? That's BS. As long as he imports his model classes into models.py, Django won't give a poo poo what files they're originally defined in. It's all just Python.
|
# ? Aug 1, 2009 02:36 |
|
bitprophet posted:Er, what? That's BS. As long as he imports his model classes into models.py, Django won't give a poo poo what files they're originally defined in. It's all just Python. He'll need to define app_label in the inner Meta class as well, but yeah.
|
# ? Aug 1, 2009 02:51 |
|
bitprophet posted:Er, what? That's BS. As long as he imports his model classes into models.py, Django won't give a poo poo what files they're originally defined in. It's all just Python. Well I was obviously being somewhat sarcastic, but I am a firm believer in using the common formatting standards for the language at hand. Of course the compiler isn't going to care how you format poo poo, just as it wouldn't care if you name all your variables x, xx, xxx, etc. Your code's going to suck and be unmaintainable though. Chances are, a programmer looking at python code is going to be most comfortable with python's common standards. If you use java standards, you're far more likely to confuse them. You'll also find yourself doing unnecessary translation when reusing code snippets, and you'll likewise be confused when editing other peoples' code.
|
# ? Aug 1, 2009 02:52 |
|
As mentioned above it seems like the issue here is entirely the java-esque desire to use one file per class. This makes sense when the language dictates that you write copious amounts of boilerplate code but in python when you can get as much done with a tenth of the amount of code it just doesn't make sense. Have a read of this article that goes into this in much more detail. I'm not sure if this is the original one that came to mind but it was the first google result so I assume it is.
|
# ? Aug 1, 2009 06:47 |
|
Thanks for the links, guys. Old habits die hard and so forth, but at least I don't feel so alone anymore. I kept trying to explain to the main python guy at work what I wanted to do and he just kept asking "why would you want to do that?!?", failing to understand where I was coming from.
|
# ? Aug 1, 2009 12:50 |
|
I just noticed something that is missing from the OP. A list of good web hosts! I just started using http://www.webfaction.com/ and after dicking around with other hosts these guys are a dream to work with. Being able to SSH into the my shared hosting and configure my own apache server is amazing! Before that I tried using A small orange, and it didn't work out too well.
|
# ? Aug 1, 2009 15:57 |
|
devilmouse posted:I realize that's how django wants it done, but not how I want to do it. I hear you man. I adore django, but occasionally I want to start punchups with it for letting you put functions outside of classes. I grew up on smalltalk (hence my Obj C love) so Im a bit of an OO zealot.
|
# ? Aug 1, 2009 17:59 |
|
MEAT TREAT posted:I just noticed something that is missing from the OP. A list of good web hosts! Hey thats a pretty neat thing. I'm still a slicehost guy, but for smaller projects thats a pretty good deal.
|
# ? Aug 1, 2009 18:01 |
|
duck monster posted:I hear you man. I adore django, but occasionally I want to start punchups with it for letting you put functions outside of classes. I grew up on smalltalk (hence my Obj C love) so Im a bit of an OO zealot. First class functions are the loving balls - and it's a python thing - not Django
|
# ? Aug 1, 2009 23:35 |
|
If I wanted first class functions I woulda stuck with scheme. *thats* how you do functions right.
|
# ? Aug 2, 2009 12:09 |
|
Newbie question about forms. I followed the tutorial on djangoproject.com and have a Poll model and a Choice model. I'd like to create a form where a user can create a poll and a few choices in one go like I can in the admin view. What is a good way to accomplish this? I looked through the documentation and just started confusing myself with save_m2m() and inlineformsets and I don't know what else.
|
# ? Aug 4, 2009 01:44 |
|
spencer for hire posted:Newbie question about forms. You're going to be wanting to look at ModelForms, and inlineformest_factory.
|
# ? Aug 4, 2009 01:52 |
|
What's people favourite choice / method for creating multi-stage forms in Django? I'd like a solution where on the one page a user can click forwards (and backwards) through a multipart form.
|
# ? Aug 4, 2009 10:12 |
|
outlier posted:What's people favourite choice / method for creating multi-stage forms in Django? I'd like a solution where on the one page a user can click forwards (and backwards) through a multipart form. Do you mean like a Form Wizard?
|
# ? Aug 4, 2009 15:23 |
|
deimos posted:Do you mean like a Form Wizard? I was looking for something that kept the form on a single page, but that's a start. (Apologies if this feature is incredibly well known, but I'm relatively new to Django.)
|
# ? Aug 4, 2009 16:02 |
|
I have a question about an application I'm trying to setup right now on my server. It's a great questionnaire application I found called seantis-questionnaire, and is the best such application I've found that is written in Django. You can check out the github repository at http://github.com/rmt/seantis-questionnaire/tree/master. You can also check out an example of this application at http://questionnaire.corporatism.org/. I have everything setup on my server, and I can get the questionnaire to pop-up and edit it without any problems. The problem I am experiencing is not being able to access some of the built in management features of this application, such as CSV export and the sending of e-mail invitations. The urls.py file looks like this code:
code:
If anybody here has any ideas, I would appreciate it immensely. If you need more information and would be willing to help me figure this out, then you can e-mail me at discopoland (at) gmail.com since I don't have PMs and let me know what you'd request in return. This is for a school project and I've got a kid on the way so I'm not flush with cash but will see what I can do.
|
# ? Aug 4, 2009 22:42 |
|
I have a question about developing a Django application that interacts with a REST API. I posted a question on Stack Overflow (http://stackoverflow.com/questions/1225701/well-behaving-restful-client-interactions) first, but I didn't do a very good job of explaining my problem (though I did get a couple good replies). Here's the premise: I have a REST API that tries to adhere to HATEOAS and REST architectural rules. I want to design a Django application to consume that API (adhering to these rules as well), but I want all the application logic and user interactivity (the frontend) to be contained within the Django application itself. Since I can't seem to adequately describe the problem (likely a sign of poor design decisions to start, but let's ignore that for now), an example is easiest (JSON responses for simplicity). code:
code:
Thanks in advance for any help. entr0py fucked around with this message at 04:00 on Aug 5, 2009 |
# ? Aug 5, 2009 03:58 |
|
Can anyone offer an explanation of what an app should consist of? I can't really understand when something should be factored out into an "app" and when it's part of a main Django site. I would like a few concrete examples, if you know of any, or could make any up.
|
# ? Aug 5, 2009 05:04 |
|
LOLLERZ posted:Can anyone offer an explanation of what an app should consist of? I can't really understand when something should be factored out into an "app" and when it's part of a main Django site. I would like a few concrete examples, if you know of any, or could make any up. http://www.youtube.com/watch?v=A-S0tqpPga4
|
# ? Aug 5, 2009 05:11 |
|
reksio posted:
It looks like you need to use a custom management command for sending emails (http://github.com/rmt/seantis-quest...naire_emails.py) Details are here: http://docs.djangoproject.com/en/dev/howto/custom-management-commands/#howto-custom-management-commands I think you should be able to just run ./manage.py questionnaire_emails
|
# ? Aug 5, 2009 17:05 |
|
Thanks for the help mwarkentin. I tried running the e-mail command from the terminal, but got tripped up because "QUESTIONNAIRE_DEFAULT not in settings" but at the same time I have searched the code and cannot figure out what this setting is supposed to be set at. Since my project I am working on for school is to do stats analysis on questionnaire results, the CSV export to me is a probably the most important aspect to get this up and running. The problem with this is that the application wants me to pass my questionnaire ID (qid) to the export_csv view, but I have no idea what this ID is. If somebody could take a look at this I would be super grateful, and my offer still stands if somebody would be willing to help me with these issues for some sum we can both agree on.
|
# ? Aug 6, 2009 01:22 |
|
king_kilr posted:You're going to be wanting to look at ModelForms, and inlineformest_factory. Thanks. I guess I just needed to look at it more closely and actually do some trial and error. Is there a way to required a minimum number of forms for an inlineformset? is_valid() does not throw an error for blank fields unless the form is partially complete. I'd like to throw a "this field is required" error if at least 2 Poll choices aren't entered.
|
# ? Aug 6, 2009 01:54 |
|
spencer for hire posted:Thanks. I guess I just needed to look at it more closely and actually do some trial and error. You'd have to subclass BaseInlineFormset and overide is_valid() to do that logic, there isn't an option for it like max_num or extra.
|
# ? Aug 6, 2009 02:01 |
|
When should I use a OneToOneField, and when should I use ForeignKey(unique=True)? For example, the Django Book's section on user profiles uses ForeignKey(User, unique=True) in the profile. I'd expect it to use a OneToOneField; is there any reason that's not done in the example?
|
# ? Aug 7, 2009 17:11 |
|
pokeyman posted:When should I use a OneToOneField, and when should I use ForeignKey(unique=True)? In .96 (which the original DjangoBook was written for) OneToOneFields were fairly hosed up, for example the automatically became primary keys. Personally I would always ues OneToOneFields for that stuff because it changes the reverse accessor, and that's very useful to crazy people like me who have automatic caching on gets by pk
|
# ? Aug 7, 2009 21:09 |
|
|
# ? May 15, 2024 02:33 |
|
Sounds reasonable. I figured there'd be something like that, and I'm glad to hear it's no longer an issue. It just seemed silly getting a queryset back from a de facto one-to-one field.
|
# ? Aug 7, 2009 23:28 |