Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Form - Select foreign key from bootstrap modal pop up
I have created a js/ajax modal pop up in a form to help select an option for a foreign key field in the form. I am lost on how to pass the selected variable back to the form and close the modal. Here is my code : views.py def worker_wizard_popup(request, pk): data = dict() shift = Shift.objects.get(id=pk) skilled = EmployeeSkill.objects.filter(skill_id=shift.skill.id).values_list('employee_id', flat=True) on_other_shifts = ShiftWorker.objects.filter(shift_date=shift.date, employee_id__in=skilled).order_by('employee__first_name') on_other_shifts_ids = on_other_shifts.values_list('employee_id', flat=True) time_off = TimeOff.objects.filter(start_date__lte=shift.date, end_date__gte=shift.date, employee_id__in=skilled).exclude(Q(start_date=shift.date, start_time__gte=shift.shift_start)|Q(end_date=shift.date, end_time__lte=shift.shift_start)).order_by('employee__first_name') time_off_ids = time_off.values_list('employee_id', flat=True) available = User.objects.filter(id__in=skilled, is_active=True).exclude(Q(id__in=on_other_shifts_ids)|Q(id__in=time_off_ids)|Q(admin=True)).order_by('first_name') context = { 'shift': shift, 'on_other_shifts': on_other_shifts, 'time_off': time_off, 'available': available } data['html_form'] = render_to_string('events/includes/partial_availability_wizard.html', context, request=request, ) return JsonResponse(data) Here is the form where I want the chosen FK to pass to the selected option of the Employee field. <div class="col-lg-6 mb-4 bg-default"> <div class="card"> <div class="card-header">Add Worker</div> <div class="card-block"> {% bootstrap_form_errors form %} <form method='POST'> {% csrf_token %} <button type="button" class="btn btn-info btn-md js-worker-wizard mb-2" data-url="{% url 'events:worker_wizard' pk=shift.id %}"><span class="fas fa-hat-wizard fa-lg"></span> Shift Wizard</button> {% bootstrap_field form.employee %} {% bootstrap_field form.shift_date %} {% bootstrap_field form.shift_start %} {% bootstrap_field form.shift_end_date %} {% bootstrap_field form.shift_end_time %} {% bootstrap_field form.call_location %} {% bootstrap_field form.pay_rate %} {% if request.tenant.preferences.request_confirm == True %} {% bootstrap_field form.request_confirm %} {% … -
403 Forbidden Apache with Django
This is will probably get downvoted, but please before do, take in mind I am a complete newbie and desperate. I want to deploy my Django site with Apache server, I tried several pages -including Django's- and previous questions, either super old or incomprehensible, but I managed to pull off this httpd.conf for VirtualHost: ServerName 127.0.0.1 Listen 5000 <VirtualHost *:5000> ServerAlias localhost ServerAdmin webmaster@example.com DocumentRoot /home/kxdragon/server/myproj/renderer/templates #Alias /robots.txt /usr/local/www/documents/robots.txt #Alias /favicon.ico /usr/local/www/documents/favicon.ico #Alias /media/ /usr/local/www/documents/media/ <Directory /home/kxdragon/server/myproj/renderer/templates> <IfVersion < 2.4> Order allow,deny Allow from all </IfVersion> <IfVersion >= 2.4> Options Indexes FollowSymLinks Includes ExecCGI Require all granted </IfVersion> </Directory> WSGIDaemonProcess example.com processes=2 threads=15 display-name=%{GROUP} WSGIProcessGroup example.com WSGIScriptAlias / /home/kxdragon/server/myproj/myproj/wsgi.py <Directory /home/kxdragon/server/myproj/> <IfVersion < 2.4> Order allow,deny Allow from all </IfVersion> <IfVersion >= 2.4> Options Indexes FollowSymLinks Includes ExecCGI Require all granted </IfVersion> </Directory> </VirtualHost> And I have no idea why this returns 403, the answer for the other questions with same issue is very old and not updated, and sorry if this -most probably- answered before. Thanks. -
Python (Django) - Authenticate returning None
I'm using Django's authenticate function to let users register (create an account) and sign in (login after creating an account). Authenticate works fine for registration, but when I try signing the user in after logging out, it doesn't work. Registration Method: if request.method == 'POST': form = SignUpForm(request.POST) if form.is_valid(): form.save() username = form.cleaned_data['username'] raw_password = form.cleaned_data['password1'] user = authenticate(username=username, password=raw_password) #returns user object login(request, user) #works Sign in Method: if request.method == 'POST': form = AuthenticationForm(request=request, data=request.POST) if form.is_valid(): username = form.cleaned_data['username'] password = form.cleaned_data['password'] user = authenticate(user=username, password=password) #returns None login(request, user) #doesn't work I looked at a few other threads that reported a similar issue and added the following code to my settings.py file. However, authenticate still returns none when I try signing in. settings.py code AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', ) -
run python script when django is runing under docker
I am working on a django docker image and I want to execute an function ussing command line, I know that I can enter to shell python docker container and run a function like this : docker container ls to find the container id and use in the next command docker container exec -it <container_id> python3 manage.py shell Then: [GCC 8.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> >>> from xx import foo >>> foo() # foo() has been excecuted However, i was wondering if i can use something similar like python flag -c which help to run small piece of python code as command line like this: python3 -c "from xx import foo; foo()" I tried to insert a cmd with linux tubes : echo 'from xx import foo; foo()' | docker container exec -it <container_id> python3 manage.py shell, However it doesn't work. I'd appreciate any advice, thanks for your time. -
How to call REST APIs from Django?
Not new to programming, but new to Django Where do I place the code in my Django project that calls an external REST API? In the simplest example: I have a form where the user enters their ZIP code and presses a "Check" button which tells if the customer's address can be serviced by the lawn care company. Upon getting a response, I have to the JSON to determine if it's serviceable, and what kind of services, etc. So I need to be able to send, and read responses. Where do I do this? There is no database involved, so I presume I don't use a model. I don't think the "View" is a good spot Where?! Thanks! -
Hello, Im trying to use Django on PyCharm and when im trying to: example "from django.shortcuts import render"
If someone could help me it would mean a lot to me as I have spending so much time trying to fix this. Im having this issue in a different projects too. -
Faker() raised Django ImproperlyConfigured Error
trying to run some fake data using Faker but been trying for a day now to solve and i cant. i need a little help here would be much appreciated below is the code and the error. im working on Windows 10, Sqlite, python 3.8.2 and django 3 and venv enviroment python -m venv name i have the django admin on already i do not know what would be the problem now... any help would be much appreciated. Thank you! import django import os import random from faker import Faker from first_app.models import AccessRecord, WebPage, Topic os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'first_app.settings') django.setup() fake = Faker topics = ['Search', 'Social', 'Marketplace'] def add_topic(): # t = Topic.objects.get_or_create(top_name=fake.name()) t = Topic.objects.get_or_create(top_name=random.choice(topics))[0] t.save() return t def populate(n=5): for entry in range(n): top = add_topic() fake_url = fake.url() fake_date = fake.date() fake_name = fake.company() webpge = WebPage.objects.get_or_create(topic=top, url=fake_url, name=fake_name)[0] fkacc = AccessRecord.objects.get_create(name=webpge, date=fake_date)[0] if __name__ == '__main__': print("Populating script") populate(20) print("Done!!") Error message: raise ImproperlyConfigured( django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable e DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings . I've tried multiple way to try an access Django's setting module but its not working i believe … -
Django query get all A records with B records
My django project has a many to many relationship Doctor -- Speciality I'm trying to list only specialities with doctor records to allow users request an appointment. Just now I have this context['specialities'] = [s for s in Speciality.objects.all() if s.doctor_set.all()] but it's not an elegant solution. I wanna list only specialities with active (is_active=True) doctors. How can I add is_active filter? -
Annotate sum of timestamp in Django queryset
Is there a way by which I can annotate sum of timestamps in django. I am trying to do something like this: qs = MyModel.objects.annotate(sum_of_completed_time=Sum('mappings__completed_at')) when i try to do this i get following error: django.db.utils.ProgrammingError: function sum(timestamp with time zone) does not exist ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts. so is there a way I can achieve this? -
Django only runs by command line but not in PyCharm
I'm trying to run a Django (version 2.1) project in PyCharm, and the run configurations are properly set to work with the right environment and to use the manage.py file to run the server. At least with other projects in PyCharm I can run without problems. But why I only get the following error django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured only when running directly from PyCharm? By command line it runs perfectly fine with the command 'python manage.py runserver'. -
Fetch foreign key object in React from Django API
I have a model in my Django API with a foreign key for the parent, which references itself. I've serialized the data and returned it in a viewset. It returns an object in which the parent field shows the parent ID as an int. However, I'm trying to get it to display the actual values of the parent instead (name and category), so that I can then render the relevant data in my React frontend app. I've listed my model, serializer and viewset below, along with the object it's returning that shows the parent and also the child with the parent ID in the parent field. Can anyone please help? class ComponentModel(models.Model): name = models.CharField(max_length=50, blank=False) wattage = models.PositiveIntegerField(blank=True, null=True) category = models.CharField(max_length=13, choices=CATEGORY_CHOICES, blank=False) parent = models.ForeignKey( 'self', blank=True, null=True, on_delete=models.CASCADE ) class ComponentSerializer(serializers.ModelSerializer): class Meta: model = ComponentModel fields = ('id', 'name', 'wattage', 'category', 'parent') class ComponentViewSet(viewsets.ModelViewSet): queryset = ComponentModel.objects.all() serializer_class = ComponentSerializer [ { "id": 1, "name": "AMD", "wattage": null, "category": "cpu", "parent": null }, { "id": 5, "name": "760K", "wattage": 100, "category": "cpu", "parent": 1 } ] -
What means "Quit the server with CTRL-BREAK"?
Do i have to press keys "Ctrl" and "Break" on my keyboard or do i have to simply type "Ctrl-break" to my terminal?? Can't figure it out still. Have tried all possibilities. Sorry for such a dumb question. -
Can't update DB using HTML form in Django
I need to fill the field name and image to upload to the Django DB but I can't make it to update it using the form label of HTML views.py """Artist views.""" # Django from django.shortcuts import render, redirect from django.views import View from django.http import HttpResponse # Models from music.models import Artist # Forms from artist.forms import ArtistForm class AddArtistView(View): """Adding new artist.""" def upload_image(request): if request.method == 'POST': form = ImageUploadForm(request.POST, request.FILES) if form.is_valid(): m = Artist.objects.get(pk=image_id) m.model_pic = form.cleaned_data['image'] m.save() return HttpResponse('Image upload success') return HttpResponseForbidden('Allowed only via POST') template = "artist/create_artist.html" def get(self, request): """Render add artist form.""" form = ArtistForm() context = {"form": form} return render(request, self.template, context) def post(self, request): """Receive and validate add artist form.""" form = ArtistForm(request.POST) if not form.is_valid(): context = {"form": form} print(form.errors) return render(request, self.template, context) new_artist = Artist.objects.create_artist( name=form.cleaned_data["name"], ) return HttpResponse("<h1>Artist Added!</h1>") models.py """Music Models""" from django.db import models class Artist(models.Model): """Artist Model.""" name = models.CharField(max_length=200) image = models.ImageField(null=True, upload_to='artists/images/') def __str__(self): """Get str representation.""" return self.name def __repr__(self): """Get str representation.""" return self.__str__() forms.py """Artist forms.""" # Django from django import forms #from django.contrib.auth.models import Artist from music.models import Artist class ArtistForm(forms.Form): """Add new artist""" name … -
Optional url parameter in django 2.2
I am working on a solution where in the application I would like to have an url with an optional parameter, if it is not there, the location is for Germany. Below is my code with urls for django 2.2 and view. urls.py urlpatterns = [ path('<country>', HomeView.as_view(), name='home'), ] views.py class HomeView(TemplateView): template_name = 'data/index.html' def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) queryset = DataSet.objects.filter(location=self.request.GET.get('country', 'Germany')) return context -
not getting results in django search but individual searching is working fine
my problem is when I'm adding simple functionality to individual search fields, it's working fine for single search fields, like after adding functionality for location field it's working as i wanted but after adding another functionality for another field it's not showing anything even the first field also not showing results, i think it's a very silly problem but i can't figure out that, please help me coders! (i've added html and views.py codes let me know guyz if you need anything else) html code <form action="{% url 'search-page' %}" method=""> <div class="row"> <div class="col-12 col-lg-10"> <div class="row"> <div class="col-12 col-md-6 col-lg-3"> <select name="location" id="location" class="form-control"> <option value="">Location</option> {% for key,value in location_choices.items %} <option value="{{ key }}">{{ value }}</option> {% endfor %} </select> </div> <div class="col-12 col-md-6 col-lg-3"> <select name="types" id="types" class="form-control"> <option value="all-types">All Types</option> {% for key,value in property_choices.items %} <option value="{{ key }}">{{ value }}</option> {% endfor %} </select> </div> <div class="col-12 col-md-6 col-lg-3"> <select name="city" id="city" class="form-control"> <option value="01">All City</option> {% for key,value in city_choices.items %} <option value="{{ key }}">{{ value }}</option> {% endfor %} </select> </div> <div class="col-12 col-md-6 col-lg-3"> <select name="status" id="all" class="form-control"> <option value="01">Status</option> {% for key,value in status_choices.items %} <option value="{{ key … -
How logout from Djoser (installed with Django Rest Framework)
I have installed Djoser with Django Rest Framework, after loggin in as (url : /token/login ) I receive a token, but when I change url to '/token/logout/ ' it shows error as logging credential not provided. I am using browser url section to interact with DRF. Please advice me correct url to logout ? I can provide Token,username and password. -
How to design a Django API to handle a "Dynamic" form?
I have built an Angular form that contains a form array. So the user has the control to add fields or delete fields from the form. What I am trying to understand is how I can design a Django API that can handle the post for this kind of dynamic form? I do not want the user to create an account on the website in order to place his order. Is that even possible? -
django formset displaying wrong objects
when creating a new recipe post, I use two formsets for ingredients and directions. however, the new post formsets are being populated by existing ingredient and direction objects when they should be empty. here is my view for the new post and the forms: def post_new(request): form = PostForm() ingredient_form = IngredientFormSet(prefix='ingredient_form') direction_form = DirectionFormSet(prefix='ingredient_form') if request.method == "POST": form = PostForm(request.POST, request.FILES) ingredient_form = IngredientFormSet(request.POST, prefix='ingredient_form') direction_form = DirectionFormSet(request.POST, prefix='direction_form') if form.is_valid(): post = form.save(commit=False) post.author = request.user post.published_date = timezone.now() post.save() if ingredient_form.is_valid(): for i_form in ingredient_form: if i_form.is_valid() and i_form.has_changed(): i_form.instance.recipe = post i_form.save() if direction_form.is_valid(): for d_form in direction_form: if d_form.is_valid() and d_form.has_changed(): d_form.instance.recipe = post d_form.save() return redirect('post_detail', pk=post.pk) return render(request, 'blog/post_edit.html', {'form': form, 'ingredient_form': ingredient_form, 'direction_form': direction_form}) class PostForm(forms.ModelForm): class Meta: model = Post fields = ['title', 'image', 'text', 'prep_time', 'cook_time', 'servings_first', 'servings_second', 'tags'] IngredientFormSet = modelformset_factory(Ingredient, fields=['name', 'int_amount', 'float_amount', 'measurement' ], extra=15) DirectionFormSet = modelformset_factory(Direction, fields=['text', 'order' ], extra=25) -
Django Web Application Reverse for '/register' not found. '/register' is not a valid view function or pattern name
I'm new in Django, and have one problem. I'm learning with a book "Django Web Application" that is quite old I think. base.html {% load static %} <!DOCTYPE html> <html> <head> <title>{% block title %}{% endblock %}</title> <link href="{% static 'css/base.css' %}" rel="stylesheet"> </head> <body> <div id="header"> <span class="logo">Bookmarks</span> {% if request.user.is_authenticated %} <ul class="menu"> <li {% if section == "dashboard" %}class="selected"{% endif %}> <a href="{% url 'dashboard' %}">Panel główny</a> </li> <li {% if section == "images" %}class="selected"{% endif %}> <a href="#">Obrazy</a> </li> <li {% if section == "people" %}class="selected"{% endif %}> <a href="#">Osoby</a> </li> </ul> {% endif %} <span class="user"> {% if request.user.is_authenticated %} Witaj, {{ request.user.first_name }}! <a href="{% url 'logout' %}">Wyloguj</a> {% else %} <a href="{% url 'login' %}">Zaloguj</a> {% endif %} </span> </div> <div id="content"> {% block content %} {% endblock %} </div> </body> </html> urls.py from django.contrib import admin from django.urls import path from django.conf import settings from django.conf.urls.static import static from django.conf.urls import include, url import account.views urlpatterns = [ path('admin/', admin.site.urls), path('', include('app.urls', namespace='app')), url(r'^account/', include('account.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) urls.py x2 from django.conf.urls import url from . import views from django.urls import path, include urlpatterns = [ #url(r'^login/$', views.user_login, name='login'), path('accounts/', include('django.contrib.auth.urls')), … -
How to add 2 codes into settings without overwriting
I have 2 projects one is website with image and one is just the music site im trying to bring music file into my site but the settings is giving me some issues. how do I add both directory's in settings.py without disrupting one or the other? This is the settings code I want to add PROJECT_DIR = os.path.dirname(os.path.abspath(__file__)) STATIC_ROOT = os.path.join(PROJECT_DIR, 'static') PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__)) STATICFILES_DIRS = ( os.path.join(PROJECT_ROOT, '..', 'static'), ) MEDIA_URL = 'media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') This is the code i don't want to overwrite as it leads to the html webpage. STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'fork/static') ] STATIC_ROOT = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' -
Django DateField cannot be None
I'm really struggeling wih the DateTime cannot be None Issue of Django (3.0.4). I Know this is a known Issue on Stackoverflow but I'm not able to solve it. I do have the Field: begin_holidays = models.DateField(null=True, blank=True) And now if a submit a form where request.POST['begin_holidays'] is not set I get the error: „“ is invalid date format. It has to be YYYY-MM-DD Has anyone an Idea ? -
How can I dynamically serve files and then make them downloadable in Django?
I'm currently working on a project that deals a lot with iCalendar files. Where after the user searches for their name on my website I would like to have an option for them to add the events shown to their phone calendars. The way I imagined that could be done is by creating a .ics file and when users click it the file would begin downloading based on the name of the user. So what I have made so far is a Django view that that when the "Add to Calendar" button is pressed, the view is rendered. The view would then just get the name queried and get its ics_string or the calendar data. Here is the view that i've written so far def serve_calendar(request): name = request.GET.get('name', '') ics_string = get_calendar_details(name) #the portion of code that i can't figure out return response What I am missing is how do I send this file for download to the client's machine without the need to create it on the server. I've found some answers using io.StringIO and FileWrapeprs from the Django library however they have not worked for me. Other answers I've found use the X-SendFile but that would not … -
Trouble with deploying my website through Heroku
''' 2020-03-23T22:23:26.957835+00:00 app[api]: Release v6 created by user shirlimotro7@gmail.com 2020-03-23T22:23:26.957835+00:00 app[api]: Deploy 77a43bc3 by user shirlimotro7@gmail.com 2020-03-23T22:23:35.653714+00:00 heroku[web.1]: Starting process with command :gunicorn alarm-manager.wsgi 2020-03-23T22:23:38.067910+00:00 heroku[web.1]: Process exited with status 127 2020-03-23T22:23:38.082750+00:00 heroku[web.1]: State changed from starting to crashed 2020-03-23T22:23:38.086700+00:00 heroku[web.1]: State changed from crashed to starting 2020-03-23T22:23:37.994083+00:00 app[web.1]: bash: :gunicorn: command not found 2020-03-23T22:23:40.000000+00:00 app[api]: Build succeeded 2020-03-23T22:23:44.604910+00:00 heroku[web.1]: Starting process with command :gunicorn alarm-manager.wsgi 2020-03-23T22:23:47.251714+00:00 heroku[web.1]: State changed from starting to crashed 2020-03-23T22:23:47.108337+00:00 app[web.1]: bash: :gunicorn: command not found 2020-03-23T22:23:47.235221+00:00 heroku[web.1]: Process exited with status 127 2020-03-23T22:23:48.258412+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=manager-107.herokuapp.com request_id=49ed5309-e238-424a-afbe-5cee328e4af0 fwd="87.68.68.48" dyno= connect= service= status=503 bytes= protocol=https 2020-03-23T22:23:49.102443+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=manager-107.herokuapp.com request_id=beb755a6-f5e2-4128-a768-6e0a58de3b5f fwd="87.68.68.48" dyno= connect= service= status=503 bytes= protocol=https 2020-03-23T22:26:53.132132+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=manager-107.herokuapp.com request_id=dd3f11e9-fb9f-4b74-9ac7-89fd20f1249f fwd="87.68.68.48" dyno= connect= service= status=503 bytes= protocol=https 2020-03-23T22:26:55.313805+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=manager-107.herokuapp.com request_id=f942f0c3-22cb-437b-b1f1-b55b8155e93c fwd="87.68.68.48" dyno= connect= service= status=503 bytes= protocol=https 2020-03-23T22:26:55.768444+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=manager-107.herokuapp.com request_id=45e88074-0f32-4f45-be2b-1033c638dd17 fwd="87.68.68.48" dyno= connect= service= status=503 bytes= protocol=https 2020-03-23T22:34:51.007678+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=manager-107.herokuapp.com request_id=8f3afe93-2915-448d-8896-f5fdd9e711fe fwd="87.68.68.48" dyno= connect= service= status=503 bytes= protocol=https 2020-03-23T22:45:01.620001+00:00 heroku[web.1]: State changed from crashed to starting 2020-03-23T22:45:08.107720+00:00 heroku[web.1]: … -
How to display img file in django template?
I know the title is a bit misleading but I explain everything. I am in the process of creating a store in django and there is a small problem that I do not know how to work around. Well, for each product I want to assign several photos that I save in the database. That's why I created the Photo model, which is connected to the Book model with a ForeignKey. The whole problem is that I do not know how to indicate on the store's home page one of the photos that is assigned to a specific book. Of course, there are many books on the page that are generated in a for loop. If it is helpful, I save the pictures for each book in a separate folder, the function content_file_name is responsible for that Of course, I am open to other ideas to achieve such an effect as described above. I am not sure if the path I have chosen is optimal. #models.py def content_file_name(instance, filename): ext = filename.split('.')[-1] filename = "%s.%s" % (instance.book.slug, ext) return os.path.join('books_img', instance.book.slug, filename) class Book(models.Model): title = models.CharField(max_length=100) author = models.CharField(max_length=300) publisher = models.CharField(max_length=100) price = models.FloatField() slug = models.SlugField() seller … -
Custom HTML Login Form with Django Registration Redux
How can I send the Input Data from my Form to the Django Registration Redux Backend? I know about Crispy Forms but I want to use my custom bootstrap html form. <form role="form"> <div class="form-group"> <label class="form-control-label">Email address</label> <div class="input-group input-group-merge"> <div class="input-group-prepend"> <span class="input-group-text"><i class="fas fa-user"></i></span> </div> <input type="email" class="form-control" id="input-email" placeholder="name@example.com"> </div> </div> <div class="form-group mb-4"> <label class="form-control-label">Password</label> <div class="input-group input-group-merge"> <div class="input-group-prepend"> <span class="input-group-text"><i class="fas fa-key"></i></span> </div> <input type="password" class="form-control" id="input-password" placeholder="********"> <div class="input-group-append"> <span class="input-group-text"> <a href="#" data-toggle="password-text" data-target="#input-password"> <i class="fas fa-eye"></i> </a> </span> </div> </div> </div> <div class="mt-4"><button type="submit" class="btn btn-sm btn-primary btn-icon rounded-pill" value="Log in"> <span class="btn-inner--text">Create my account</span> <span class="btn-inner--icon"><i class="fas fa-long-arrow-alt-right"></i></span> </button></div> </form>