|
Lamacq posted:I guess I don't know what you mean by "blank". some_order.assigned_to.all() should at least return an empty list. Are you sure the order instance you're working with in the interactive interpreter is the same one you're updating via the form? (I'm assuming you're using "./manage.py shell" to play with your django models in the interactive interpreter) It just seems that the ManyToManyField table isn't being populated when I submit orders, but the main Orders table is.
|
# ? Mar 31, 2011 20:29 |
|
|
# ? Jun 8, 2024 07:05 |
|
root beer posted:My bad, it does return an empty QuerySet list (<bound method QuerySet.all of []>). I have tested this in both my app and the interactive shell and it gets an empty list both times. And but when you go back to the form to edit the order that you've just saved (and presumably assigned to users), are those users still selected in the "assigned to" multiple select? Care to put up a paste of your form code, template, and the view function?
|
# ? Mar 31, 2011 20:32 |
|
Lamacq posted:And but when you go back to the form to edit the order that you've just saved (and presumably assigned to users), are those users still selected in the "assigned to" multiple select? Care to put up a paste of your form code, template, and the view function? Here's the relevant code: Relevant views: http://pastebin.com/cESdt7bx Template: http://pastebin.com/90bCg6P1 Form code (lol): code:
|
# ? Mar 31, 2011 20:49 |
|
VVVVVVVVVVV what he said
Lamacq fucked around with this message at 21:25 on Mar 31, 2011 |
# ? Mar 31, 2011 21:17 |
|
Lamacq posted:Note that you never instantiate Order objects directly; you use the Order.objects class attribute (which is a Model Manager) to create or retrieve Order instances. code:
|
# ? Mar 31, 2011 21:23 |
|
Yay posted:Additional note: calling form.save() should do the work of Order.objects.create for you. (Aside: what's wrong with creating instances of Order()? I've never encountered anything that said that was bad, nor have I had any problems with it)
|
# ? Mar 31, 2011 23:51 |
|
Yay posted:(side: what's wrong with creating instances of Order()? I've never encountered anything that said that was bad, nor have I had any problems with it) Nothing, but be sure to call .save() on the instance if you want it to actually exist, also you can't establish FK/M2M relations until you call .save() because until you do it won't have an id assigned to it.
|
# ? Apr 1, 2011 00:22 |
|
Any good ufarn fucked around with this message at 00:33 on Apr 1, 2011 |
# ? Apr 1, 2011 00:30 |
|
Yay posted:Additional note: calling form.save() should do the work of Order.objects.create for you. (Aside: what's wrong with creating instances of Order()? I've never encountered anything that said that was bad, nor have I had any problems with it) You probably need `order.save_m2m()` as well.
|
# ? Apr 1, 2011 00:31 |
|
king_kilr posted:You probably need `order.save_m2m()` as well. `form.save_m2m()` I think you mean. `save_m2m` is defined on the ModelForm, not the Order instance IIRC.
|
# ? Apr 1, 2011 02:06 |
|
Lamacq posted:`form.save_m2m()` I think you mean. `save_m2m` is defined on the ModelForm, not the Order instance IIRC. Yep, changing my model to code:
Edit: I lied. Now I added a ForeignKey relationship from the Orders model to an Orders_Description model, and although the form correctly generates a nice big <textarea> for me, but the form throws an error and says the description field is blank whether it is or not. I had this happen to me once before and I fixed it by upgrading from 1.2.5 to 1.3. Should I just install nightly builds every time I see this error? Edit2: Every time I try to submit the form, it says "Select a valid choice. That choice is not one of the available choices." for the description ForeignKey. The form is generating it as a <textarea> as expected. What the gently caress? DICTATOR OF FUNK fucked around with this message at 18:24 on Apr 1, 2011 |
# ? Apr 1, 2011 15:44 |
|
Lamacq posted:`form.save_m2m()` I think you mean. `save_m2m` is defined on the ModelForm, not the Order instance IIRC. , I think I'm going to go commit something to forms to drown my sorrows.
|
# ? Apr 1, 2011 18:17 |
|
king_kilr posted:, I think I'm going to go commit something to forms to drown my sorrows. No worries dude. You've committed about a billion times more worth to python & django than I ever will.
|
# ? Apr 1, 2011 18:26 |
|
If any Django developers here are looking for a part time / contracting remote engagement with the possibility of full time employment if things go well, please send me a PM with note about your experience, a resume and phone number. Background: In January, I cofounded a company in the advertising optimization space and we have had a reasonable amount of success but are unable to build things as fast as we would like and have a large backlog of projects. We are based in San Francisco. The other cofounder and I both have an engineering background. I've been working with Django for about 6 months, he has been working with it for 3.5 years and knows it inside and out. If this is the wrong place for this, I'm happy to move it to another thread or forum.
|
# ? Apr 8, 2011 00:27 |
|
I've been hunting around trying to find the answer for this, and only found information regarding normal forms. Where do you put custom validation/clean for a ModelForm? I have a field that I need to strip out everything but numbers, and check if its below a certain number.
|
# ? Apr 8, 2011 06:43 |
|
hitze posted:I've been hunting around trying to find the answer for this, and only found information regarding normal forms. Where do you put custom validation/clean for a ModelForm? I have a field that I need to strip out everything but numbers, and check if its below a certain number. Edit: for your purposes, models.PositiveIntegerField, combined with a defined integerfield with max_value ought to work. Yay fucked around with this message at 18:55 on Apr 8, 2011 |
# ? Apr 8, 2011 18:51 |
|
I just released this, hope somebody finds it useful.
|
# ? Apr 8, 2011 19:04 |
|
Lamacq posted:I just released this, hope somebody finds it useful. This looks great, I was wishing for something like this last month. How does it play with 1.3? vvv Edit: Descent: Freespace epswing fucked around with this message at 20:08 on Apr 8, 2011 |
# ? Apr 8, 2011 19:22 |
|
epswing posted:This looks great, I was wishing for something like this last month. How does it play with 1.3? I tested it with 1.3, if you have any problems go ahead and file a bug report BTW is your avatar from Ground Control? I really should finish that game one of these days...
|
# ? Apr 8, 2011 19:46 |
|
Yay posted:ModelForms are (simplistically speaking) just Forms bound to a Model class, so the topic on Form validation is still relevant; see cleaning a specific field, and just below that, the notes on inter-dependent cleaning. code:
hitze fucked around with this message at 03:22 on Apr 10, 2011 |
# ? Apr 10, 2011 01:01 |
|
I'm trying to put together what I need for django-registration to work...I'm designing activation_email.txt which contains a link users should click to activate their account. It appears {% url registration_activate activation_key=activation_key %} returns /accounts/activate/somehashgoeshere/ while {{ site }}/accounts/activate/{{ activation_key }}/ produces example.com/accounts/activate/somehashgoeshere/ I'm not sure where example.com is defined and where I can override it. The settings.py file has a SITE_ID but I don't think that's what I'm looking for. Google searches are getting me unrelated pages, I'm probably not searching for the right keyword. Any advice?
|
# ? Apr 10, 2011 08:49 |
|
epswing posted:I'm trying to put together what I need for django-registration to work...I'm designing activation_email.txt which contains a link users should click to activate their account. Look in your database for a table called ``django_site``. The SITE_ID in your settings file is referencing a row in this table; by default the first record has the domain "example.com".
|
# ? Apr 10, 2011 12:54 |
|
Yep, you can edit it in the admin.
|
# ? Apr 13, 2011 14:24 |
|
Anyone have experience playing with Django and Google Apps? I'm in the design stages of an application for a domain that has business hosted Gmail. I'd love it if there's a way to authenticate users with Google Accounts but Google's single sign on documentation isn't exactly clear on this subject unless I'm explicitly using Google App Engine or something that appears to support Django 0.97.
|
# ? Apr 28, 2011 03:59 |
|
edit: Nevermind hosed up the url.py
duck monster fucked around with this message at 09:14 on Apr 29, 2011 |
# ? Apr 29, 2011 08:48 |
|
Is there a better way of getting all instances in a ModelFormSet than something like the following:code:
|
# ? May 1, 2011 17:56 |
|
I'm having a hell of a time with South (yet again! I'm becoming very unclear as to the benefit of this loving thing vs just manually tracking database changes when its so god drat fragile and prone to exploding) convincing it to shut the gently caress up about django-cms. The thing seems to have some very broken migrations and whilst it seems it'll install fine with a syncdb, it just vomits blood anywhere that involves south. The problem is the solution as far as I can tell is to just tell south to shut the gently caress up about it. As per the manual;- quote:SOUTH_MIGRATION_MODULES = { Which leads to this.. code:
Is there something that I *should* be using that just says SOUTH_PLEASE_SHUT_THE_FUCK_UP_ABOUT = ( 'cms' ) Souths a great idea and all that but it gets into horrifying knots with off-the-shelf modules, and I really suspect its a pretty dangerous tool to use with mission-critical data, particularly when combined with postgres's seemingly endless capacity to light itself on fire.
|
# ? May 4, 2011 05:57 |
|
duck monster posted:I'm having a hell of a time with South (yet again! I'm becoming very unclear as to the benefit of this loving thing vs just manually tracking database changes when its so god drat fragile and prone to exploding) convincing it to shut the gently caress up about django-cms. The thing seems to have some very broken migrations and whilst it seems it'll install fine with a syncdb, it just vomits blood anywhere that involves south. I've used django-cms a whole bunch, and only once had a problem with migrations, where south couldn't understand one, either because the version of south stopped supporting the declaration style, or because of a regression in django-cms (which would seem odd, because why would you recreate a migration?) What errors are you getting trying to migrate the cms? And are you using the latest releases of South/django-CMS?
|
# ? May 4, 2011 11:21 |
|
Yay posted:What errors are you getting trying to migrate the cms? And are you using the latest releases of South/django-CMS? Yes, pip'd within the week. One of the sub apps (content type or whatever it is) complains about a null value in content type id , and , uh, some crap about a missing relationship. I cant even find where cms stores its migration files For now I'm just going to nuke south and start again from the current state. I dont have time to go micromanaging souths wierd temper tantrums, especially when it loving ignores my request not to manage the cms app.
|
# ? May 4, 2011 11:35 |
|
duck monster posted:One of the sub apps (content type or whatever it is) complains about a null value in content type id , and , uh, some crap about a missing relationship. Is it asking you about a stale content type, possibly?
|
# ? May 4, 2011 15:53 |
|
Cross posting from Stack Overflow, hoping some goon here has a smart solution for me. I need to upload and attach an arbitrary number of images to my model. The site is for an estate agent, so they want to attach images to the property pages of their site. I can only think of the following solutions: Create another model for the images and associate them using a ManyToMany field. There are many reasons why I don't want to do this, mainly because it confuses the process of adding a new property (they'd have to go two different admin screens) and since there could be thousands of properties, finding them in the ManyToMany drop down would be a real pain. Create a rather complicated custom widget which launches a popup with a image model. The problem here is that I need to ensure that the images are linked to the property once it has been saved, so I need to figure out a way of doing that (since when you add a new property, there is nothing to create a link to.) I know I could do this with signals, but I'm unsure as to how I'd do this with multiple images since there could be more than one value to associate. Does anyone have any suggestions as to how I can do this? Fundamentally I just need a way of uploading a dynamic number of images and somehow associating them with my model.
|
# ? May 5, 2011 09:30 |
|
Hanpan posted:Cross posting from Stack Overflow, hoping some goon here has a smart solution for me. I would guess that just adding an image model with a ManyToMany field, and then using custom widgets/forms to make it display how you would like is the best solution. There's no reason why you have to use the default drop down menu or have multiple admin screens.
|
# ? May 5, 2011 12:21 |
|
Hanpan posted:I need to upload and attach an arbitrary number of images to my model. The site is for an estate agent, so they want to attach images to the property pages of their site. I can only think of the following solutions: This is pretty much exactly what the admin inlines do. Make your M2M model that's linked back to the property, set up an admin inline for it, and you'll have a new section at the bottom of your property edit page where they can upload new images. There'll even be a delete button for deleting the linked image models. If you need to provide ordering, alt text, etc, you'll want to use a custom through model, which will make it a bit less clean.
|
# ? May 5, 2011 18:34 |
|
Yea, admin inlines is what I needed. I feel like a loving fool for not knowing about these sooner.
|
# ? May 6, 2011 14:52 |
|
Hanpan posted:Yea, admin inlines is what I needed. I feel like a loving fool for not knowing about these sooner. The great thing about them is that they're just another form, so you can do anything to them you'd want to do to any other admin form (replace widgets with previews, etc).
|
# ? May 6, 2011 17:50 |
|
If I recall there used to be an issue with one of the migrations that django-cms had and sqlite. If you are using sqlite this could be your problem.
|
# ? May 7, 2011 05:53 |
|
This might be too inspecific a question for this thread, but here goes. Just this week I decided I wanted to learn more about web development and web applications, and as I've been using Python for a couple of years it seemed appropriate to learn Django. I went through the tutorial on the official page, and am looking at djangobook and some other tutorials on other sites. It's all making sense, and I'm looking forward to making my own programs. What I'm curious about is presentation of the sites you make. All the tutorials have simple examples of HTML layout in the templates they have you make, but never really go into much depth about it and its really just there so you can see the results of the views they have you create. The more I look into it, it seems that web development and web design are decoupled, and Django understandably is structured with this in mind. Django appears to cater for the development side, and nothing relating to Django touches much on the design side. What I've learned so far has been through looking at the admin templates/CSS files in the Django distribution and Inspecting Elements in Chrome. So my questions are: is my observation about Django not involving itself with design correct, and; where should I go to learn how to make pages which don't look like they are from 1993? I expect there are a bunch of tools out there to help with layout and CSS design. EDIT: is it kosher to copy/use the admin interface's styling and layout? xPanda fucked around with this message at 05:39 on May 11, 2011 |
# ? May 11, 2011 03:13 |
|
xPanda posted:So my questions are: is my observation about Django not involving itself with design correct, and; where should I go to learn how to make pages which don't look like they are from 1993? I expect there are a bunch of tools out there to help with layout and CSS design. Yes, design and development are *relatively* decoupled. They do influence each other but not anything approaching massive amounts and could be handled on their own. It's a bit of the whole "form follows function/function follows form" debate, I guess. I don't see any problem with copying the admin but I'd probably put some sort of disclaimer stating that you used their design, etc. As for learning web design, read sites like A List Apart and check out Forrst and the like. I can get you an invite to Forrst if you need it, btw (or anyone else here for that matter). A lot of it will come from you developing a designer's eye for details, which is something you can't learn solely from reading books/web sites.
|
# ? May 11, 2011 09:29 |
|
MonkeyMaker posted:I can get you an invite to Forrst if you need it, btw (or anyone else here for that matter). epswing fucked around with this message at 18:15 on May 11, 2011 |
# ? May 11, 2011 14:44 |
|
|
# ? Jun 8, 2024 07:05 |
|
MonkeyMaker posted:I can get you an invite to Forrst if you need it Sounds great! Sending PM.
|
# ? May 12, 2011 01:52 |