read this here I think this'll explain what you're wanting. http://docs.djangoproject.com/en/dev/ref/forms/validation/
On Tue, Sep 21, 2010 at 1:50 PM, Anton Danilchenko < anton.danilche...@gmail.com> wrote: > Message - this is a rental proposition (rooms, floor, cost, area, > country, cirty and contact phones). > > Visitors can create new messages (message - this is a rent > proposition) and enter list of own phones (one or more phones). My > application store this phones not in char field, but save each phone > number to separate Phone morel - one phone in one model). If phone > already exists - message attached to this phone. If phone not exists - > we create new phone and attach message to this phone number. > > In future, I tell to people - and see that this people not a good > man :-). I go to my application and mark this phone number to black > list. All future messages from this people to be marked as bad > messages. > > Now I need to create own Form field called MultiPhoneField based on > CharField widget, but implenet logic of ManyToManyField. I need show > for user CharField where user enter comma separated phone numbers. I > check this numbers and if all numbers correct - store this numbers in > database in Phone model (each phone in separate record) and associate > message with list of this phones. > > Can you please help me in this. I not understand how to create my own > Field based on ManyToManyField. > > Thanks! > > On 21 сен, 21:16, "nick.l...@gmail.com" <nick.l...@gmail.com> wrote: > > Personally....I don't like the idea of adding multiple phone numbers as > > comma separated values. What happens when a user's trying to add more > phone > > numbers than your charField's max_length? > > > > So let me see if I understand what's going on here... > > > > You have a problem where exists apartments for rent. People who want to > rent > > these apartments will send messages to the owner of said apartment > (through > > your website). This message will have associated to it, a User and > Multiple > > Phone Numbers. > > > > This message is then checked to see if the phone numbers associated to it > > have been black listed... > > And then finally deliver the message? > > > > n > > > > On Tue, Sep 21, 2010 at 12:15 PM, Anton Danilchenko < > > > > > > > > > > > > anton.danilche...@gmail.com> wrote: > > > I describe my task more reallistical. > > > > > This is application for rent an apartment. User can create new message > > > with information about apartment, and also add one or more contact > > > phone numbers. One user, without registration, can create more that > > > one message on the site. For one message can add one phone number, for > > > other message add two phones. > > > > > I need to save only one copy of phone number in database in format > > > XXXXXXXX. For each phone I can set if this phone in black list or not > > > (model Phone have property "blocked" by default setted to False). > > > > > I want to save phone numbers in model Phone, and messages in model > > > Message. But, people can see input text field (CharField) where enter > > > one or more phone numbers separated by comma. > > > > > class Phone(models.Model): > > > number = models.CharField(max_length=20) > > > blocked = models.BooleanField(default=False) > > > > > class Message(models.Model): > > > # ... information about count of rooms, floor, cost, etc ... > > > phones = models.ManyToManyField(Phone) > > > > > Nick, thank you for you help. You are really very good people! > > > > > On 21 сен, 18:12, "nick.l...@gmail.com" <nick.l...@gmail.com> wrote: > > > > Maybe I don't understand your problem. > > > > > > It sounds to me like your trying to make this way more difficult than > it > > > > needs to be. > > > > > > Also it sounds to me like your trying to assign the same phone number > to > > > > multiple people. (which is fine) But doesn't make a lot of sense to > me in > > > a > > > > practical application. > > > > > > n > > > > > > On Tue, Sep 21, 2010 at 9:59 AM, Anton Danilchenko < > > > > > > anton.danilche...@gmail.com> wrote: > > > > > In my case, I have Users with equal phone numbers. And I need only > > > > > ManyToMany relationship. > > > > > > > I need create custom field for get information from CharFiels, > > > > > validate this data, clean and save to datastore in separate model. > If > > > > > this phone already exists - we get ID of this phone. And, if this > is a > > > > > new phone number - we insert this phone to separate model and get > new > > > > > ID. > > > > > > > -- > > > > > 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<django-users%2bunsubscr...@googlegroups.com> > <django-users%2bunsubscr...@google groups.com> > > > <django-users%2bunsubscr...@google groups.com> > > > > > . > > > > > For more options, visit this group at > > > > >http://groups.google.com/group/django-users?hl=en. > > > > > > -- > > > > Guadajuko! Vamos a correr! > > > > -"Cool! we are going to run!" > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Django users" group. > > > To post to this group, send email to django-us...@googlegroups.com. > > > To unsubscribe from this group, send email to > > > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > <django-users%2bunsubscr...@google groups.com> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/django-users?hl=en. > > > > -- > > Guadajuko! Vamos a correr! > > -"Cool! we are going to run!" > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- Guadajuko! Vamos a correr! -"Cool! we are going to run!" -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.