logo
down
shadow

Django - How to add items to Bootstrap dropdown?


Django - How to add items to Bootstrap dropdown?

Content Index :

Django - How to add items to Bootstrap dropdown?
Tag : python , By : ChristianM
Date : January 11 2021, 03:34 PM

it should still fix some issue Your code looks fine. However if request.user.is_authenticated is False: prevents the people from passing into your html page. Just remember to authenticate to view the full drop down menu :)

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

Add items to Bootstrap Dropdown from Code Behind


Tag : chash , By : Amin Amini
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I have a dropdown from boostrap such as this: , You will need a repeater.
Repeater1.DataSource = yourdatasource
    Repeater1.Databind()


<asp:Repeater id="Repeater1" runat="server">
<HeaderTemplate><Ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1"></HeaderTemplate>
<ItemTemplate>

    <li role="presentation">
        <a role="menuitem" href="#"> <%# Eval("yourfieldfromcodebhind here") %> </a>

    </li>
</ItemTemplate>
</asp:Repeater>

Bootstrap Dropdown expands but does not contain any Items


Tag : html , By : Dmitry
Date : March 29 2020, 07:55 AM
should help you out Using Bootstrap you dont need
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />
</head>

<body>


        <!--Default buttons with dropdown menu-->
        <div class="btn-group">
            <button type="button" data-toggle="dropdown" class="btn btn-default dropdown-toggle">Action <span class="caret"></span></button>
            <ul class="dropdown-menu">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li class="divider"></li>
                <li><a href="#">Separated link</a></li>
            </ul>
        </div>
        <!--Primary buttons with dropdown menu-->



</body>

Bootstrap button dropdown child element's class is getting removed when clicked on other button's dropdown items


Tag : javascript , By : baylisscg
Date : March 29 2020, 07:55 AM
it fixes the issue The problem occurs because you are using parents instead of parent:
This line of code is the problem:
thisEl.parents('li').siblings().find('a').removeClass('active-select'); // parents targets all li's above `a` and hence siblings afterwards targets other drop-downs.
thisEl.parent('li').siblings().find('a').removeClass('active-select');
	(function () {
		var search_btn = $('.select-style').find('button.btn-inverse'),
			selectOptions = $('.select-style ul.dropdown-menu li').find('a');

		selectOptions.on('click', function (e) {
			e.preventDefault();

			var thisEl = $(this);
			var getTextData = thisEl.text();

			thisEl.addClass('active-select');
            // Use .parent and not .parents
			thisEl.parent('li').siblings().find('a').removeClass('active-select');

			thisEl.parents('.btn-group').find('button[type=button]').html( getTextData );
		});
	}) ();
ul.homeInputBaropenState { list-style-type: none; width: 500px; }
ul.homeInputBaropenState li { display: inline;  }
ul.homeInputBaropenState li a.active-select { color: blue; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

<ul class="select-Section homeInputBaropenState">
                <li class="select-style">
                    <div class="btn-group">
                        <button type="button" class="btn btn-inverse dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    Select City
                        </button>

                        <ul class="dropdown-menu">
                            <li><a href="#">New York</a></li>
                            <li><a href="#">San Fransisco</a></li>
                            <li><a href="#">Los Angeles</a></li>
                            <li><a href="#">Detroit</a></li>
                        </ul>
                    </div>
                </li> 

                <li class="select-style">
                    <div class="btn-group">
                        <button type="button" class="btn btn-inverse dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    Select Type 
                        </button>
                    
                        <ul class="dropdown-menu">
                            <li><a href="#">Men</a></li>
                            <li><a href="#">Women</a></li>
                            <li><a href="#">Kids</a></li>
                        </ul>
                    </div>
                </li>

                <div class="clearfix"></div>
            </ul>

Creating Django Filter in a bootstrap dropdown based on the django-admin created categories


Tag : django , By : Gerhard Miller
Date : March 29 2020, 07:55 AM
hope this fix your issue In accordance to the comment given by @TimS and some other helps from another community, I wrote a solution to filter by category and it works.
Below is the hack that made its work:
<div class="row" style="margin-bottom: 50px;">
    <div class="col-sm-6 pull-right">
        <form method="get">
            <select id="men-filter-cat" class="form-control" name="category-filter" onchange="this.form.submit();">
                <option value="all">Filter by category</option>
                {% for c in categories %}
                    <option value="{{ c.category }}" {% if selected == c.category %}selected=selected"{% endif %}>
                        {{ c.category }}
                    </option>
                {% endfor %}
            </select>
        </form>
    </div>
</div>
class HomeView(View):
    def get(self, request, *args, **kwargs):
        mentors = Mentor.objects.all()
        chosen_filter = self.request.GET.get('category-filter')
        if chosen_filter:
            mentors = mentors.filter(category__category=chosen_filter)
        return render(request, "mentoring_application/home.html", {"mentors": mentors, 'selected': chosen_filter, 'categories': Category.objects.all().order_by('category')})


def profile(request, pk, template='mentoring_application/profile.html'):
    mentor = get_object_or_404(Mentor, pk=pk)  # pk is primary key, so url will be site.com/profile/3
    context = {'mentor': mentor}
    return render(request, template, context)

Responsive Bootstrap 4 navbar dropdown-items display as nav-items


Tag : development , By : Habikki
Date : March 29 2020, 07:55 AM
will be helpful for those in need Use a @media query for mobile (<992px) to show the dropdown-menu as normal nav-links...
@media (max-width: 992px) {
    .dropdown-toggle {
        display: none;
    }

    .dropdown-menu {
        display: block;
        position: relative;
        border-width: 0;
        padding: 0;
        margin: 0;
    }

    .dropdown-item {
        padding: .5rem 0rem;
        color: rgba(0,0,0,.5);
    }
}
Related Posts Related QUESTIONS :
  • How can I scrape text within paragraph tag with some other tags then within the paragraph text?
  • Custom entity ruler with SpaCy did not return a match
  • Logging with two handlers - one to file and one to stderr
  • How to do pivot_table in dask with aggfunc 'min'?
  • This for loop displays only the last entry of the student record
  • How to split a string by a specific pattern in number of characters?
  • Python 3: how to scrape research results from a website using CSFR?
  • Setting the scoring parameter of RandomizedSeachCV to r2
  • How to send alert or message from view.py to template?
  • How to add qml ScatterSeries to existing qml defined ChartView?
  • Django + tox: Apps aren't loaded yet
  • My css and images arent showing in django
  • Probability mass function sum 2 dice roll?
  • Cannot call ubuntu 'ulimit' from python subprocess without using shell option
  • Dataframe Timestamp Filter for new/repeating value
  • Problem with clicking select2 dropdownlist in selenium
  • pandas dataframe masks to write values into new column
  • How to click on item in navigation bar on top of page using selenium python?
  • Add multiple EntityRuler with spaCy (ValueError: 'entity_ruler' already exists in pipeline)
  • error when replacing missing ')' using negative look ahead regex in python
  • Is there a way to remove specific strings from indexes using a for loop?
  • select multiple tags by position in beautifulSoup
  • pytest: getting AttributeError: 'CaptureFixture' object has no attribute 'readouterror' capturing stdout
  • Shipping PyGObject/GTK+ app on Windows with MingW
  • Python script to deduplicate lines in multiple files
  • How to prevent window and widgets in a pyqt5 application from changing size when the visibility of one widget is altered
  • How to draw stacked bar plot from df.groupby('feature')['label'].value_counts()
  • Python subprocess doesn't work without sleep
  • How can I adjust 'the time' in python with module Re
  • Join original np array with resulting np array in a form of dictionary? multidimensional array? etc?
  • Forcing labels on histograms in each individual graph in a figure
  • For an infinite dataset, is the data used in each epoch the same?
  • Is there a more efficent way to extend a string?
  • How to calculate each single element of a numpy array based on conditions
  • How do I change the width of Jupyter notebook's cell's left part?
  • Measure distance between lat/lon coordinates and utm coordinates
  • Installing megam for NLTK on Windows
  • filter dataframe on each value of a samn column have a specific value of another column in Panda\Python
  • Threading with pubsub throwing AssertionError: 'callableObj is not callable' in wxPython
  • Get grouped data from 2 dataframes with condition
  • How can I import all of sklearns regressors
  • How to take all elements except the first k
  • Whats wrong with my iteration list of lists from csv
  • Tensorflow Estimator API save image summary in eval mode
  • How to Pack with PyQt - how to make QFrame/Layout adapt to content
  • How do I get certain Time Range in Python
  • python doubly linked list - insertAfter node
  • Open .h5 file in Python
  • Joining a directory name with a binary file name
  • python, sort list with two arguments in compare function
  • Is it possible to print from Python using non-ANSI colors?
  • Pandas concat historical data using date minus some number of days
  • CV2: Import Error in Python OpenCV
  • Is it possible to do this loop in a one-liner?
  • invalid literal for int() with base 10: - django
  • Why does my code print a value that I have not assigned as yet?
  • the collatz func in automate boring stuff with python
  • How to find all possible combinations of parameters and funtions
  • about backpropagation deep neural network in tensorflow
  • Sort strings in pandas
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com