cb_dj_dependent_dropdown's People
Forkers
hafismuhammed joblackpoc ahmednayel-1 sagar0802 beethoven9 yankzy moussabe iacz mrbappy99 ranafaraz shaidsifat daminisuthar amanjha8100 heniljshah sreenivasulu009 jczaragoza obago369 kolgolar xythercoder shubhamgoel01 ramyhelmy16 ppraeeprae polleyamilya antonycode genesisblock3301 shemajolivetgislain fuadsanin klausnovello santhosh-joy graham218 todoviernessmk isaacky sendoo-m jasorglez gaurav-9648 lucasamiranda stefanorhel tabishkhan96 kslg eseymenler aseelaslam a-athul-a chanrley jairochoa tangngocphung madariyaprakash dehesscb_dj_dependent_dropdown's Issues
Fix to avoid NoneType error.
Some people may encounter the error of 'NoneType' object has no attribute 'city_set' if you implement this to a profile system or any other similar model. My way around to fix it was :
if 'country' in self.data:
try:
country_id = int(self.data.get('country'))
self.fields['city'].queryset = City.objects.filter(country_id=country_id).order_by('name')
except (ValueError, TypeError):
pass # invalid input from the client; ignore and fallback to empty City queryset
elif self.instance.pk:
try:
self.fields['city'].queryset = self.instance.country.city_set.order_by('name')
else:
pass
Regarding the Chain Dropdown Menu
Is there a better way to do that because if you look at the steps and start imagining a bigger project, the coding style wouldn't be pleasing at all.
for one dropdown menu, you had to do a lot of things, imagine if you have 10s of them.
please if there is a better way to deal with it, share.
Thanks a lot for the wonderful lesson, but it didn't work with the update.
if I want to update, the chain dropdown shows all the cities regardless of the country, even though in the elif self.data.instance.pk is mentioned, and I think this is related to update. I could be wrong, but it didn't work with update in my case.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.