Can Anyone Please Provide djago-select2 Documentation

237 views
Skip to first unread message

Balaji Shetty

unread,
May 15, 2019, 1:12:46 AM5/15/19
to django...@googlegroups.com
Hi

I need Cascading drop down list in Django Admin GUI.

I have bee trying to use Django-select2 but i am not getting the desired output.
( Example Select Continents, select respective Country under Continent )

Can Anyone Please Provide djago-select2 Documentation or any other simple alternative. I want to use django admin Panel only. I am not designing any form

I will appreciate your help.

--
Mr. Shetty Balaji S.
Asst. Professor
Department of Information Technology,
SGGS Institute of Engineering & Technology, Vishnupuri, Nanded.MH.India
  Mobile: +91-9270696267

Julio Cojom

unread,
May 15, 2019, 2:06:21 AM5/15/19
to django...@googlegroups.com
Hi, I used a package exclusive for admin, it call django-select2-admin and it's magic. Only register in installed apps and that's all.

Regards.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAECSbOuAhpUOrq8OvLFi3dFZtkoU703zWpW5RmzWkEGBa9GcSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Balaji Shetty

unread,
May 15, 2019, 2:28:00 AM5/15/19
to django...@googlegroups.com
Hi Julio Cojom

Thank You very much for your reply.
Can you please provide me the web link for necessary package installation and steps also.
I have been trying since 4 hour and tried all the option for select2 from different web sites still could not get success.
I will really appreciate if you do it.
Please.



For more options, visit https://groups.google.com/d/optout.

Test Bot

unread,
May 15, 2019, 2:46:47 AM5/15/19
to django...@googlegroups.com
Okay so there is no need to go to different websites if you want to install a Python module. You will find almost everything related to Python modules in pypi.org, it includes everything like installation instructions, gut repo for the packages etc

Balaji Shetty

unread,
May 15, 2019, 3:05:55 AM5/15/19
to django...@googlegroups.com
Thank once again. I followed the instruction but i am not getting any changes.
Can you please see the error.

models.py

from django.db import models

# from django import forms
# from django_select2.forms import ModelSelect2MultipleWidget

class Continent(models.Model):
    name = models.CharField(max_length=255)

    def __str__(self):
         return self.name


class Country(models.Model):
    continent = models.ForeignKey(Continent,on_delete=models.CASCADE)
    name = models.CharField(max_length=255)

    def __str__(self):
         return self.name

class Location(models.Model):
    continent = models.ForeignKey(Continent,on_delete=models.CASCADE)
    country  = models.ForeignKey(Country,on_delete=models.CASCADE)
    city = models.CharField(max_length=50)
    street = models.CharField(max_length=100)


    def __str__(self):
         return self.name
------------------------------------------------------

admin.py

from django.contrib import admin

from .models import Continent,Country, Location


admin.site.register(Country)
admin.site.register(Location)
admin.site.register(Continent)
# Register your models here.

-----------------------------------------------------------------------

setting.py

 Application definition

INSTALLED_APPS = [
    'django_select2',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'newapp',  #My App Name
]
------------------------------------

I downloaded PAckage





For more options, visit https://groups.google.com/d/optout.

Balaji Shetty

unread,
May 15, 2019, 4:53:45 AM5/15/19
to django...@googlegroups.com
Correction in Previus Model

class Location(models.Model):
    continent = models.ForeignKey(Continent,on_delete=models.CASCADE)
    country  = models.ForeignKey(Country,on_delete=models.CASCADE)
    city = models.CharField(max_length=50)
    street = models.CharField(max_length=100)


    def __str__(self):
         return self.city

Julio Cojom

unread,
May 15, 2019, 11:03:54 AM5/15/19
to django...@googlegroups.com
Hi again,

The package is this : pip install django-admin-select2

It didn't have docs, just the git page (django-admin-select2) with a readme, its really easy, does all you need but you cant customize.


Regards.


Balaji Shetty

unread,
May 15, 2019, 2:11:55 PM5/15/19
to django...@googlegroups.com
Hi  Julio Cojom,

Sorry .
I request , please do this favour on me. I have been searching from morning but could not get any success.

Please run zip file and see the mistake and let me know please.

I will be thankful.

I followed the instructions and I successfully installed django-admin-select2.

But i do not get Cascading Drop down updates for country and city.I get all city under all countries.

Here is my Code

 I have also attached Project Zip File.
Project are working and we can add Country,City and Map Model data.


models.py


from django.db import models

class Country(models.Model):

    name = models.CharField(max_length=255)

    def __str__(self):
        return self.name

class City(models.Model):
    name = models.CharField(max_length=
255)
    country = models.ForeignKey('Country', related_name="cities",on_
delete=models.CASCADE)


    def __str__(self):
        return self.name


class map1(models.Model):
     name = models.CharField(max_length=255)
     continent = models.ForeignKey(Country,on_delete=models.CASCADE)
     country = models.ForeignKey(City,on_delete=models.CASCADE)

     def __str__(self):
        return self.name

------------------------------------------------------

admin.py

from django.contrib import admin

from .models import Country,City,map1

admin.site.register(Country)
admin.site.register(City)
admin.site.register(map1)
-----------------------------------------------------------------------

setting.py

INSTALLED_APPS = [
    'django_admin_select2', # Necessary Package

    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'newapp', # App Name
]

------------------------------------


For more options, visit https://groups.google.com/d/optout.
demo1.zip

Balaji Shetty

unread,
May 16, 2019, 8:00:48 AM5/16/19
to django...@googlegroups.com

Hi

Can anyone please provide me the resource for implementation of Cascading Dependent Drop Down List in Django Admin GUI.

I do now want to write any code and use existing Admin GUI only. I tried many select2 but could not get any success.

Here is my sample code....
--
demo1.zip

carlos

unread,
May 16, 2019, 10:47:04 AM5/16/19
to django...@googlegroups.com

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

For more options, visit https://groups.google.com/d/optout.


--
att.
Carlos Rocha

Balaji Shetty

unread,
May 16, 2019, 1:40:01 PM5/16/19
to django...@googlegroups.com
Dear carlos
Thank You very much.


For more options, visit https://groups.google.com/d/optout.


--

Balaji Shetty

unread,
May 17, 2019, 11:19:14 AM5/17/19
to django...@googlegroups.com
Hi

but could not understand how to use it. I am new in Django. I could add Cascading drop down as well as retrieve.
But how to use it in my code is the difficulty.

Can  anyone help me in getting Cascading interdependent drop down Features with Foreign Key in Admin GUI only.
Reply all
Reply to author
Forward
0 new messages