Coder Social home page Coder Social logo

Comments (7)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 21, 2024
I was wondering if there's any update on this feature?

I'm currently working on something like this, and was curious of the best 
approach.  
One can just check if the ajax results come back empty AND user enters some 
text, then 
just create the new foreign field automatically.

Original comment by [email protected] on 3 Mar 2010 at 6:46

from django-ajax-selects.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 21, 2024
I just added support for adding via a pop up. (green +)

@yevmail You can do what you want to do by using an AutoComplete.  have the 
channel search for models and 
return the name of the object.  in your form implement clean_fieldname() and at 
that point lookup the model by 
name using YourModel.objects.get_or_create(name=name) and insert it into 
cleaned_data[fieldname].  I think that 
should work

Original comment by [email protected] on 6 Mar 2010 at 12:02

from django-ajax-selects.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 21, 2024
[deleted comment]

from django-ajax-selects.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 21, 2024
Has anyone got this working?

I had to modify the clean() method on the form field, but that method gets the 
foreignkey (pk-value) passed after validation and will not receive the actual 
text input (name). If the input does not match an existign FK object, the value 
passed to clean() will be empty and there is no request object to grab the text 
input from, so no way to Model.objects.get_or_create.

I would really like to see this feature implemented.

Original comment by [email protected] on 22 Sep 2010 at 4:06

from django-ajax-selects.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 21, 2024
Hi, I need to resurrect this. crucialfelix, can you please show how to do it? 
I'd like to look at some code I can then integrate with mine. Thanks!

Original comment by [email protected] on 7 Dec 2010 at 3:30

from django-ajax-selects.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 21, 2024
Some code to look at would help a lot. But since last activity was a year ago, 
maybe Felix won't make it available.

Original comment by [email protected] on 6 Dec 2011 at 7:07

from django-ajax-selects.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 21, 2024
The code has moved to https://github.com/crucialfelix/django-ajax-selects

as for this feature, to be honest I am driven by my own client's needs and I 
haven't needed this.

just off the top of my head thinking about it :  use an AutoComplete field (not 
a foreign key one) and give it a unique field name that is not on the model.  
implement Form save() and you should have access to the 
cleaned_data['fake_field'] and can get_or_create there and set the fk on the 
instance.

Original comment by [email protected] on 6 Dec 2011 at 8:30

from django-ajax-selects.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.