Re: raise ValidationError has no effect
2009/4/8 brian <bbiermans...@gmail.com>: > > I think I'm having the same issue. Did you ever find a solution? > Yea, Karen Tracey was right in my case: > On Feb 14, 5:06 pm, Karen Tracey <kmtra...@gmail.com> wrote: >> On Sat, Feb 14, 2009 at 11:07 AM, Alistair Marshall < >> this is covered here: >> >> http://docs.djangoproject.com/en/dev/ref/forms/validation/ >> >> where it states: >> >> As mentioned, any of these methods can raise a ValidationError. For any >> field, if the Field.clean() method raises a ValidationError, any >> field-specific cleaning method is not called. However, the cleaning methods >> for all remaining fields are still executed. >> >> The clean() method for the Form class or subclass is always run. If that >> method raises a ValidationError, cleaned_data will be an empty dictionary. >> >> The previous paragraph means that if you are overriding Form.clean(), you >> should iterate through self.cleaned_data.items(), possibly considering the >> _errors dictionary attribute on the form as well. In this way, you will >> already know which fields have passed their individual validation >> requirements. >> >> The idea is to get all the problems identified, as far as possible, and not >> let the first error encountered stop the process. That way (hopefully) all >> the problems can be noted with error messages in one go-round with the user, >> rather than having submit, here's an error, fix one error, resubmit, here's >> a 2nd error, fix, resubmit, here's a 3rd error, etc. >> >> Karen > the forms clean function is called without all the required data in the cleand_data field. the solution - add an extra check in the clean function to ensure all the required data is there before running the rest of the checks -- Alistair Marshall www.thatscottishengineer.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: raise ValidationError has no effect
On Feb 15, 12:06 am, Karen Traceywrote: > The previous paragraph means that if you are overriding Form.clean(), you > should iterate through self.cleaned_data.items(), possibly considering the > _errors dictionary attribute on the form as well. In this way, you will > already know which fields have passed their individual validation > requirements. > You know I would have sworn I had read that page fully several times now. Clearly not. You are right, I had expected it to stop after finding the first error, but this way makes more scene. I'll just have to make sure my second part of the validation has all the required information before it starts to validate it. Thanks again Alistair http://www.thatscottishengineer.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
raise ValidationError has no effect
I have been trying to create a custom field that allows the user to enter a flowrate and clean the data back to kg/s or mol/s. I though I had everything sorted, when I type '10 tones/year', it correctly did the conversion however when I type something that does not validate such as 'twenty' or '5 mph' the code runs till the raise validation error, however nothing else happens and the overall forms clean function gets called (which doesn't have all the fields in its clean_data attribute. I have posted the code on dpaste, any hints or suggestions and would be greatly appreciated (this is hurting my head now) http://dpaste.com/120538/ Thanks Alistair http://www.thatscottishengineer.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: move/change database type
On Jan 21, 7:54 pm, joshuajonahwrote: > A normal manage.py dump to fixture doesn't work? > I had missed that one, didn't know it was an option. my bad Thanks Alistair --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
move/change database type
Hi folks, I have been developing a project on my desktop using sqlite, I have just attempted to move it onto a 'proper' server and was hoping to use mysql. The thing is I have some data in the database from some beta users and was hoping to take the data over with the move. I had planned on using db_dump.py which has worked in the past but this time it wont work, I _think_ the problem is to do with the fact that this time I am using multi-table model inheritance. I was wondering what other tools where out there (I surely cant be the only one trying to do this) Thanks Alistair --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
drawing diagrams in django?
hi folks, I am currently trying to create an app which allows the user to generate flowsheets (of a chemical plant) So far I have created all the basics and allow the user to enter information about the individual unitsw chemicals etc and the user can even run a simulation. what I now want to do is create a graphical overview of the process. I want to be able to draw out the flowsheet to an image and perhaps even allow the user to click on areas of the image to be linked to that section of the process. Currently I have a very rough function that generates x,y coardanites of each unit (though this could be improved greatly). All I really need is a simple method of drawing lines (or arrows), saving them to a png, and returning the saved location. I was wondering if anyone else had a simalar drawing requirement and to ask what they use Thanks Alistair --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: inlineformset_factory KeyError after updating
2009/1/6 <j...@fairviewcomputing.com>: > The problem is this bit in main_form.html, around line 37: > > {% ifnotequal field.label "Id" %} > {{ field }} > {% endifnotequal %} > > The omitted ID is causing your KeyError; leave it in the form. > Excellent, It had been removed to neaten the form. Silly really. Thanks for that Alistair -- Alistair Marshall www.thatscottishengineer.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: inlineformset_factory KeyError after updating
I have created a cut down version of my project and placed it on my website [1] The project was part of a pinax project, though I have ripped out the main app and made it stand alone. As a result there is no facility to login or manage accounts. I have commented out or removed all parts of permissions checking in my views, so now anyone can edit the example. Background: The project is a preliminary example of a chemical engineering process simulation suite. This would allow the user to design a chemical process and keep track of flowrates etc. For this example, I have removed a number of the more complex features, including the ability to run the actual simulation. The main basis of the process revolves around units. Each unit is a node in the process, which may have streams flowing in or out (a non-symmetric many-to-many relationship through Stream). In this example I have only left 3 basic units: Feed - inserting components into a process Mixer - mixing 2 streams together Product - a stream out of the process The Bug: After creating a new process the user has to enter components the want to use in the process. Then the user creates a units. Mixers and Products are boring and don't require much information. The feed on the other hand needs to know the feed-rate at which to insert components. This is done with an inline formset on the same page. The feed rates are stored in a many-to-many relationship with components through FeedFlowrate. When creating a new feed unit the system works fine. However if you go and edit an existing feed unit, an error gets thrown when saving the form. I think that's covered most things - any suggestions/comments welcome Thanks Alistair [1] http://www.thatscottishengineer.co.uk/code/impress.zip -- Alistair Marshall www.thatscottishengineer.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: inlineformset_factory KeyError after updating
2009/1/5 Alistair Marshall <thatscottishengin...@gmail.com>: Upgraded to 1.0.2 I'll try and create a cut down version-that may take some time (it is getting to be a large project) Thanks -- Alistair Marshall www.thatscottishengineer.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: inlineformset_factory KeyError after updating
2009/1/5 Karen Tracey <kmtra...@gmail.com>: > First, I would try 1.0.2 release or current trunk or 1.0.X branch instead of > 1.0. There have been additional fixes in this area that you may need, > depending on what you are doing. > Just upgraded now - no difference > If that doesn't fix it, please post some specifics of what you are doing > exactly. > Not sure what information you want, here is a copy of one of the models files: http://dpaste.com/105625/ I have a view that displays a form for the sepunit and a formset of the split fractions It is fine when submitting a new sepunit, but updating an old one gives the error mentioned in my first email. What other information is needed? thanks -- Alistair Marshall www.thatscottishengineer.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
inlineformset_factory KeyError after updating
I appear to be having the same trouble as explained in a previous thread [1] (and for some reason cant find the button to reply to the last thread ???) The other thread points to a bug that was fixed before django 1.0 (which is what I am running) I am not (intentionally) doing anything funny with the primary keys. I have a the formset is for a model created by using a through relationship in a many-to-many field. Any suggestions would be greatly welcomed Thanks The trackback error : http://dpaste.com/105590/ [1] http://groups.google.com/group/django-users/browse_thread/thread/862e60c6b19a5f88 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Combine model form with a formset
I have been hunting around but can't find a solution to this problem: It is probably best described with an example Example: class Author(models.Model): name= models.CharField() location = models.CharField() class Book(models.Model): name= models.CharField() author = models.ForeignKey(Author) I want to be able to enter/edit details about both the author AND the books the author has written in the same form/view - I have tried using a form wizard though I have just gotten lost and am not sure if this is the best method of solving this or if it is even possible to include a formset within a form wizard. Has anyone else had this user case and is there a best method? Thanks Alistair --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: model inheritance - getting data from child objects
On Nov 7, 4:19 pm, Gerard flanagan <[EMAIL PROTECTED]> wrote: > I don't know if it's clever or stupid, but this is what I have done in a > similar situation: > It appears to be a nice solution - it throws an error If I try to get_related() on a generic non-specialised place rather than just returning itself, but I don't think that will be a problem for this application. -- update actually this can be fixed with a try except statement: #- class Item(models.Model): typecode = models.CharField(max_length=30, editable=False) def save(self, force_insert=False, force_update=False): self.typecode = self.__class__.__name__.lower() super(Item, self).save(force_insert, force_update) def get_related(self): try: return self.__class__.__dict__[self.typecode].related.model.objects.get(id=self.id) except: return self class SubItem(Item): #- Thanks Alistair -- Alistair Marshall www.thatscottishengineer.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: model inheritance - getting data from child objects
On Nov 6, 2:22 pm, Thomas Guettler <[EMAIL PROTECTED]> wrote: > If all worker classes (cook, waiter, ...) are subclassed from Worker, > something like this should work: Worker.objects.filter(workplace=...) > Unfortunately the function that each child will run is a bit more complicated than just listing workers. It involves output of different equations depending on the class. Think of it like calculating rents for the different Places and the rate of rent depends on both the size of the Place and the type of the place (ie a charity shop might have a lower rate) As I said, I have the function named the same in each child class but I need to be able to access it from a list of all the Places. My current thinking is just a long list of try, except: statements attempting to call the subclass from the Place model but this feels hacky and un-clean. Alistair --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
model inheritance - getting data from child objects
Using the example in the django writing models documentation [1] I wish to get a list of all the places, then calculate a value that depends on what the type of place it is. Say in my restraunt I have a function get_workforce() which returns a list of all the people that work in the restaraunt. This collects all the waiters, cooks and managers that are associated with the restraunt. Then I have another type of place, a shop which also has a function get_workforce() which returns a list of people that work in the shop. This collects all the shop_assistants and managers associated with the shop. The function is different depending on the type of subclass but I need to be able to get access to it from a list of all the places. Has anyone come across this before and come up with a solution. Thanks Alistair [1] http://docs.djangoproject.com/en/dev/topics/db/models/#id6 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Splitting models.py won't install models
Right I managed to fix it and feel really stupid at the same time but I thought I would post here in case anyone else has the same issue my mistake was using class meta: and not class Meta: doh! got to love case sensitivity. Thanks to all that offered suggestions Alistair --- Alistair Marshall http://www.thatscottishengineer.co.uk --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Splitting models.py won't install models
Ok, perhaps this is a pinax issue? I would not have thought that it would have made a difference but I'll try asking on the pinax list. Thanks for your help --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Splitting models.py won't install models
On Oct 28, 1:43 pm, patrickk <[EMAIL PROTECTED]> wrote: > you could try changing the import in __init__.py to someting like > this: > from app_name.models.model_file import Model1, Model2, ... > e.g. > from library.models.material import Material, MaterialImage > > ... might work. > Thanks for your reply, unfortunately it made no difference. If I miss type a model name or try to import from a non existent file, I get an error (as expected) however if all is typed correct I get no error but my models are still not inserted into my database. any other ideas? Thanks again --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Splitting models.py won't install models
I have been trying to split my models.py file into several smaller more manageable files. I have created a folder named models, an in there, created a __init__.py file which contains: from other import * from streams import * from units import * I have then split my models into the three files making sure to add app_label = 'process' to the metatag of each model. Then when I run 'python manage.py syncdb', It runs through and creates tables for models from other application but doesn't create any models to do with my process app. If I insert a syntax error into one of my models, it does raise an error when I syncdb. If I remove app_label, it does not raise an error or change the behaviour in any way. am I missing anything else? any other suggestions? Thanks Alistair --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---