Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Change CSS stles from view in Django
Sorry if this is an obvious question, I am new to django and still learning. I am creating a website that contains 6 images in total. The images in the website should remain invisible until its image id is passed from views.py. I have a template index.html page and view that loads when this url is accessed localhost/imageid What I need now is to make the image visible whenever its url is access. So for instance if a user goes to localhost/1. QR code 1 should be made visible. I am also storing the state of all access images. So if the user accesses the website again and goes to localhost/2 it should make image 1 and 2 visible. I am using sessions to store the state. I just need a way of making the images visible. Thankyouuuu -
Where should I initialize my MQTT Loop in Django
Currently my init.py looks like this: from . import mqtt mqtt.client.loop_start() But when I run it some actions in the loop are done more than once. When I place a time.sleep(30) in front everything works as intended. But I think this is not the best thing to do. How do I run my loop only when everything else has loaded. I tried putting it in an AppConfig ready like so: from django.apps import AppConfig from . import mqtt class PrintConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'print' def ready(self): mqtt.client.loop_start() but I get the following error: RuntimeError("populate() isn't reentrant") Is there something I need to add to my INSTALLED APPS when I use the def ready(self): function ? -
super(type, obj): obj must be an instance or subtype of type this the problem and i am pretty sude that this is because of the code in my form [closed]
i am tryna create custom user creator in admin panel class AdminUserCreation(forms.ModelForm): password1 = forms.CharField(label="password", widget=forms.PasswordInput) password2 = forms.CharField(label="password confirmation", widget=forms.PasswordInput) class Meta: model = CUser fields = ["email"] def clean_password2(self): password1 = self.cleaned_data.get("password1") password2 = self.cleaned_data.get("password2") if password1 and password2 and password1 != password2: raise forms.ValidationError("passcodes do not match!") return password2 def save(self, commit=True): user = super(UserCreationForm, self).save(commit=False) user.set_password(self.cleaned_data["password1"]) if commit: user.save() return user every time i try to create it gives me that error! -
Celery Async Issue in Django's Docker Container
I have deployed micro services on docker containers using celery for queue management. Problem is that when I call sync operation it can access database container but async operation gives us this error HTTPConnectionPool(host='database', port=83): Max retries exceeded with url: Can anybody tell me the root cause of this behavior? why the same API is executing in sync and not in async? -
Unnecessary auto migrations on Django?
running python 3.6 and Django 3.1.7! So I have a Django project with an app with models as the following: class Department(models.Model_: name = models.CharField(max_length=255) class Person(models.Model): first_name = models.CharField(max_length=255) last_name = models.CharField(max_length=255) department = models.ForeignKey( Department, related_name="department_members", on_delete=models.CASCADE ) When I run makemigrations I get this on 0001_initial.py: class Migration(migrations.Migration): initial = True operations = [ migrations.CreateModel( name='Person', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('first_name', models.CharField(max_length=255)), ('last_name', models.CharField(max_length=255)), ], ), migrations.CreateModel( name='Department', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('name', models.CharField(max_length=255)), ], ), migrations.AddField( model_name='person', name='department', field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='department_members', to='my_app.department'), ), ] That is all fine and good but now I've been getting this red text: Your models have changes that are not yet reflected in a migration, and so won't be applied. Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them. When I run makemigrations again i get this as 0002_auto_20211111_1116.py: class Migration(migrations.Migration): dependencies = [ ('my_app', '0001_initial'), ] operations = [ migrations.AlterField( model_name='Department', name='id', field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), ), migrations.AlterField( model_name='Person', name='id', field=models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'), ), ] I haven't made changes to models.py and also I can't see a difference on the 'id' field that is being altered on the auto migration. … -
How to convert Optional<Dictionary<String, Any>> to Dictionary<String, Any> to send Alamofire post request with json paramters?
class func postLoginRequest(url: String, parameters: Parameters?, success: @escaping (Any) -> Void, failure: @escaping (NetworkError) -> Void) { if Network.isAvailable { let param : [String : Any] = [ "username" : "cuyar", "password" : "cuyar" ] print (type(of: param)) print(param) print(type(of: parameters)) print(parameters) let manager = Alamofire.Session.default manager.session.configuration.timeoutIntervalForRequest = Constants.NetworkError.timeOutInterval manager.request(url, method: .post, parameters: param, encoding: JSONEncoding.default ).validate(statusCode: 200..<600).responseJSON { (response) -> Void in ... My data output like given in bellow; Dictionary<String, Any> ["username": "x", "password": "x"] Optional<Dictionary<String, Any>> Optional(["username": Optional(<TextFieldEffects.HoshiTextField: 0x11c054600; baseClass = UITextField; frame = (41 10; 286 40); text = 'x'; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x2821b45d0>; layer = <CALayer: 0x282f855c0>>), "password": Optional(<TextFieldEffects.HoshiTextField: 0x11c043600; baseClass = UITextField; frame = (41 10; 286 40); text = 'x'; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x2821afe40>; layer = <CALayer: 0x282f849c0>>)]) When ı use param as a parameters no problem. I can get username and password in backend (DJango) for jwt auth. But ı cant when ı use parameters as parameters value. How can do this convertion to send json body data. -
Django - Chaining annotated querysets
I am trying to chain two querysets that have different annotated values based on some filters (which are simplified in the following snippet) queryset = Location.objects.all() queryset_1 = queryset.filter(dummy=True).annotate(weight=Value(1, IntegerField())) queryset_2 = queryset.filter(dummy=False).annotate(weight=Value(0, IntegerField())) queryset = queryset_1 | queryset_2 However, if I iterate the queryset and try to print the weight, if will be 1 for the whole queryset for p in queryset: print(p, p.weight) 5587798: <True> 1 5587810: <True> 1 5587811: <True> 1 5587819: <False> 1 5587823: <False> 1 5587824: <True> 1 Is it possible to keep the annotated value, so the objects that are dummy=False have an annotated value of 0, and the ones that have it set to true have an annotated value of 1? -
Get specific field of model in select_related
I have a query in my project: qs = self.model.objects \ .filter(user=self.request.user, pk__iexact=pk) \ .select_related('shipping_addr', 'billing_addr', 'cart') \ .first() I want to optimize this query more than it is. I want to get only the 'id' and 'name' fields of shipping_addr. But this is not working: qs = self.model.objects \ .filter(user=self.request.user, pk__iexact=pk) \ .select_related('shipping_addr', 'billing_addr', 'cart') \ .only('shipping_addr__name','shipping_addr__id') \ .first() I know the reason that why this code is not running, I don't know what I have to do😕. -
associate the user with the post Django and MySQL
I am trying to associate the user with the post. I have two models students is for user and sublists is for user posts with a foreign key(author). I am using MySQL database and using forms to store data into them. when my form.author execute in my HTML file it gives me a list of ids for all users in the databse but I am already logged in and i want to post as the logged in user without choosing. If remove it says my form is not valid which make sense since im not inputing for form.author.Since I'm using MySQL, I'm not using the built-in User authentication method, but instead comparing both email and password with the login form input. Spend too much time on this but hard to get around with this one. Any help would be appreciated my views.py look like this def addnew(request): if request.method == 'POST': form = Sublist(request.POST) if form.is_valid(): try: form.save() messages.success(request, ' Subscirption Saved') name = sublist.objects.get(name=name) return render (request, 'subscrap/main.html', {'sublist': name}) except: pass else: messages.success(request, 'Error') pass else: form = Sublist() return render(request, 'subscrap/addnew.html', {'form': form}) @login_required(login_url='login') @cache_control(no_cache=True, must_revalidate=True, no_store=True) def main(request): return render(request, 'subscrap/main.html') def mod(request): student = students.objects.all() … -
Adding IdentityServer4 to a Django API as an OAuth2 Server
I have a Python API written using Django. I am going to use IdentityServer4 as my OAuth2 server to generate JWT for the Django application so I can add other frameworks like .NET Core to my solution later without any issues. Is that possible to use IdentityServer4 as an OAuth2 server for Django? Thanks -
Multiple django session tables
An application requires two user models for authentication. First is the AUTH USER model which has name, email and password and another is Account model which has foreign key relationship with AUTH USER MODEL. PermissionsMixin is inherited by the account model, so all the groups and permissions are related to it, rather to the AUTH USER model. User registration is done once using AUTH USER model. But login should happen in following stages. Basic authentication for AUTH USER model with email and password which will return session cookies. (say auth cookie) Using the auth cookie, user gets the list of accounts from the accounts table associated with his AUTH USER entry User sends the account_id along with the auth cookie. Backend returns new session cookie (say account cookie) for that user account and user will have all the permissions associated with that account. Problem: Django session framework authenticates only against the AUTH USER model, so how can I create account session & cookie the second time for the account model? How can I have multiple session tables for authentication? -
Cannot run django project [duplicate]
I am working on Django apps. I have a problem that, whenever I create a new Django project, I get error in browser. Precisely, I enter command "python manage.py runserver" in terminal and I open link http://127.0.0.1:8000/. In browser I get this path: http://127.0.0.1:8000/upload/, which has no relation with the app I created. I once used url "/upload/" in some app, so I suppose that it has relation with it. Please can you help me solve my problem because I don't know how to do that. -
how to get the selected radio button value from models in django
I'm doing a website in django but this is the first time i use this framework so i'm not so used to it. I need to save some information on a DB, and i need to take these information from some radio buttons. I tryied so many ways to get the data but nothing worked. So i'd like to ask how to get these data in models.py from a template,html. This is the code in views.py: def question1(request): form = CHOICES(request.POST) return render(request, 'question1.html', {'form': form}) This is the template question1.html: <form class="form-inline" method='POST' action="" enctype='multipart/form-data'>{% csrf_token %} {{form.NUMS}} </form> And then i literally don't know how to do the function in models.py -
Django - Foreign key constraint fails on delete with through model
I am working on a REST api using Django Rest and one endpoint involves deleting a Contact model, which can have multiple Addresses associated with it via ContactAddress through model. The Contact model looks like this: class Contact(AuditModel): contact_id = models.AutoField(primary_key=True) address = models.ManyToManyField('Address', through='ContactAddress') name_first = models.CharField(max_length=100) name_last = models.CharField(max_length=100) ContactAddress looks like this: class ContactAddress(models.Model): contact = models.ForeignKey('Contact', on_delete=models.CASCADE) address = models.ForeignKey('Address', on_delete=models.CASCADE) is_billing = models.BooleanField(null=True, default=False) is_shipping = models.BooleanField(null=True, default=False) And the Address model looks like this: class Address(AuditModel): address_id = models.AutoField(primary_key=True) postcode = models.CharField(max_length=30, blank=True, null=True) region = models.CharField(max_length=100, blank=True, null=True) street_line_1 = models.CharField(max_length=500, blank=True, null=True) street_line_2 = models.CharField(max_length=500, blank=True, null=True) street_line_3 = models.CharField(max_length=500, blank=True, null=True) And when trying to delete the contact like so with contact.delete() I get the following MySQL error: django.db.utils.IntegrityError: (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`mnghub`.`contact_addresses`, CONSTRAINT `contact_addresses_contact_id_cadc11a0_fk_contacts_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `contacts` (`contact_id`))') I get this error despite the contact having no addresses associated with it. I assume the constraint is because the relationship is many-to-many, but I want to be able to delete related models if they are only related with one object -
getting error while fetching urls in templates- Django
I'm trying to replicate an ecommerce website and show separate products when they click at different links of the category. But I'm having trouble with fetching the urls in the template. Here's my views.py : from django.shortcuts import render, redirect, reverse, get_object_or_404 from django.views import View from .models import Product, Category class ProductView(View): def get(self, request, *args, **kwargs): products = Product.objects.filter(is_active = True) context = { 'products': products, } return render(request, 'Product/products.html', context) class ProductDetailView(View): def get(self, request, slug): singleproduct = Product.objects.get(slug = slug) context = { 'singleproduct': singleproduct, } return render(request, 'Product/productdetail.html', context) class eBookView(View): def get(self, request, catslug): ebooks = Product.objects.filter(category__category = 'eBooks') context = { 'ebooks': ebooks } return render(request, 'Product/ebooks.html', context) class IllustrationView(View): def get(self, request, catslug): illustration = Product.objects.filter(category__category = 'Illustration') context = { 'illustration': illustration } return render(request, 'Product/downloadillustration.html', context) class PhotosView(View): def get(self, request, catslug): photos = Product.objects.filter(category__category = 'Photos') context = { 'photos': photos } return render(request, 'Product/photos.html', context) class WebsiteTemplatesView(View): def get(self, request, catslug): website = Product.objects.filter(category__category = 'Website Templates') context = { 'website': website } return render(request, 'Product/websitetemplates.html', context) Here's my urls.py : from django.urls import path from .views import ProductView, ProductDetailView, eBookView, IllustrationView, PhotosView, WebsiteTemplatesView urlpatterns = [ path('', … -
How to retrive data from more than two tables with many to many relationships What I want?
1 ) I want to add pages and pull the page meta data from pagemeta table. One page will have more than on pagemeta. PageMeta Table , will have section(many to many relationship) and key and value like: Keyname: _contact_collapse Value: People usually ask these Section Table name: _contact_us_fax ModelsMeta Table This table will have: sectionname( foreign key) model_key : choices , for example: _heading_title, _heading_paragraph meta_vale ( this is for charfield) meta_content: HTML Field What I want to achieve from this? I want to make my own kind of simple CMS where I can create dynamic pages and assign fields to pages by establishing relationship with other tables via many to many or foreign key relationship when required. Whats the problem? To publish the specific page content, I need to know the pagemeta id's of that page from that pagemeta table id's, I need to find section table related to each and from the section id I will need to find information from ModelsMeta table. From this I hope I will be able to create a cms system where I can call the other tables data from keyvalue pair. My table structure code: class SectionKey(models.Model): model_name =models.CharField(max_length=200) class Meta: … -
Django website sometimes doesn't print anything
I developed a website using Django where the HTML content is scraped data from amazon. The page's function is to scrape the data from amazon when I give a search item. I used Beautiful Soup to scrape data. When I ran the function alone without running the server, the output is fine and there is no issue. But when I used that same function in my server, sometimes I get output which is a table of scraped data. But sometimes I don't get any table in my page. I feel like the issue is from the way of adding Django in my code. As I'm new to Django, please check whether I've entered all the code correctly. The code I used is, views.py def amzlogic(response): USER_AGENT = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36" LANGUAGE = "en-US,en;q=0.5" session = requests.Session() session.headers['User-Agent'] = USER_AGENT session.headers['Accept-Language'] = LANGUAGE session.headers['Content-Language'] = LANGUAGE title_list = [] price_list = [] image_url_list = [] if response.method == "GET": search = response.GET.get("search-item") search = search.replace(" ", "+") url = f"https://www.amazon.in/s?k={search}&page=1&qid=1636019714&ref=sr_pg_1" page = requests.get(url) soup = BeautifulSoup(page.content,'lxml') for item in soup.select(".s-border-top"): title = item.select_one(".a-color-base.a-text-normal").get_text()[:25] try: price = item.select_one(".a-price-whole").get_text().replace(",", "").replace(".", "") except: price = "No Price" … -
How to change the status of the column in the model in django
I am creating an assignment management system, What a I want is whenever someone upload a submission in response to that assignment I want to change the status from pending, I will set everything on template page, but right now i feel like i have little issue with database. class Assignment(models.Model): assignment_creator = models.ForeignKey( Teacher, on_delete=models.CASCADE, related_name="assignments") assignment_title = models.CharField(max_length=30) class Submissions(models.Model): submitted_by = models.ForeignKey(Student, on_delete=models.CASCADE) submission_file = models.FileField(null=False, blank=True, default='') submitted_to = models.ForeignKey( Teacher, on_delete=models.CASCADE, null=True) submission_title = models.ForeignKey( Assignment, on_delete=models.CASCADE, null=True, blank=True) submission_status = models.BooleanField(default=False) Is there any way to know which of the assignment related to that assignment title is uploaded so that I can change the status -
Django logging not working once i switched from wsgi to asgi
Once i made a switched from wsgi to asgi in my django project, all log records stop working. can this be explained. -
DRF serializer of mocked object returns Mock object for attributes
I'm writing a pytest test and I want to mock a non-existing model, which has a nested sub-object with its own values. When I then serialize the mocked object, the data returns another mock object instead of the value for the mock. def sub_object(status): sub-object_mock = mock.MagicMock() sub-object.status = status sub-object.user = UserFactory() sub-object.created = timezone.now() return sub-object_mock @pytest.fixture def object_with_sub_object(): object_with_sub-object = mock.MagicMock() sub_object_1 = sub_object("new") sub_object_2 = sub_object("declined") object_with_sub_object.sub_object = [sub_object_1, sub_object_2] return object_with_history @pytest.mark.django_db def test_status_serializer_mixin(object_with_sub_object): output = StatusSerializerMixin(object_with_sub_object.sub_object[0]).data Checking object_with_sub_object.sub_object[0].status gives new but StatusSerializerMixin(object_with_sub_object.sub_object[0]).data["status"] gives '<MagicMock name=\'mock.status_.status\' id=\'139783810861768\'>' If I replace sub-object.status = status with sub-object.status = mock.PropertyMock(return_value=status) then object_with_sub_object.sub_object[0].status gives <PropertyMock name='mock.status' id='139783815428640'>. Any help with how to write the nested mocks is appreciated. -
am getting a popup in my browser after running te code says : an error occurred
enter image description herei don't know why am getting an error to get my urls right when i add chat/ to my project but getting it working when i change my urls to '' when i have the main application in my urls.py already with ''. urls.py from django.contrib import admin from django.contrib.auth import views as auth_views from django.urls import path, include from django.conf import settings from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), path('', include('blog.urls')), path('chat/', include('chat.urls')),] app urls.py from django.urls import path from . import views urlpatterns = [ path('', views.home, name='index'), path('<str:room>/', views.room, name='room'), path('checkview', views.checkview, name='checkview'), path('send', views.send, name='send'), path('getMessages/<str:room>/', views.getMessages, name='getMessages'), ] index.html <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <style> body { margin: 0 auto; max-width: 800px; padding: 0 20px; } .container { border: 2px solid #dedede; background-color: #f1f1f1; border-radius: 5px; padding: 10px; margin: 10px 0; } .darker { border-color: #ccc; background-color: #ddd; } .container::after { content: ""; clear: both; display: table; } .container img { float: left; max-width: 60px; width: 100%; margin-right: 20px; border-radius: 50%; } .container img.right { float: right; margin-left: 20px; margin-right:0; } .time-right { float: right; color: #aaa; } .time-left { float: left; color: #999; } </style> </head> … -
Am trying to get individual posts by a particular user. If i click on a particular users i want to get all the posts he has posted Django
Am actually new to programming, so i am just getting a blank page, no errors app_name= outcome` this is my model class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile', blank=True, null=True) bio = models.TextField(max_length=500, null=True) location = models.CharField(max_length=30, null=True) def __str__(self): return self.user.username def get_absolute_url(self): return reverse('outcome:userprofile-detail', kwargs= {'pk': self.pk }) class Post(models.Model): text = models.TextField(max_length=255) profile = models.ForeignKey('Profile', null=True, on_delete = models.CASCADE, related_name='create') overview = models.CharField(max_length=255) def __str__(self): return self.text the view class Userlist(LoginRequiredMixin, ListView): model = Profile template_name = 'outcome/user-list.html' class UserDetail(LoginRequiredMixin, DetailView): model = Profile template_name = 'outcome/userprofile_detail.html' **user_detail template** {% for i in post.profile_set.all %} **`trying to loop over the post`** {{i.text}} {% endfor %} i have tried this for a while now and i dont know whether its from template or view. -
is this an invalid use of pytest.mark.django_db?
For this example everything in the UserProfile model is optional except for the user foreign key to the user model @pytest.mark.django_db def create_userprofile_list(): full_permissions_user, _ = get_user_model().objects.get_or_create( username="admin_testuser", email="admin_testuser@user.com", is_superuser=True, is_staff=True, ) staff_permissions_user, _ = get_user_model().objects.get_or_create( username="staff_testuser", email="staff_testuser@user.com", is_superuser=False, is_staff=True, ) user_permissions, _ = get_user_model().objects.get_or_create( username="normal_testuser", email="normal_testuser@user.com", is_superuser=False, is_staff=False, ) user_list = [full_permissions_user, staff_permissions_user, user_permissions] return [UserProfile.objects.get_or_create(user=user)[0] for user in user_list] userprofile_list = create_userprofile_list() I would use the userprofile_list in other tests but I can't get this to work with the test database. the error is as follows: userprofile/tests/test_userprofiles.py:None (userprofile/tests/test_userprofiles.py) userprofile/tests/test_userprofiles.py:39: in <module> userprofile_list = create_userprofile_list() userprofile/tests/test_userprofiles.py:15: in create_userprofile_list full_permissions_user, _ = get_user_model().objects.get_or_create( /usr/local/lib/python3.9/site-packages/django/db/models/manager.py:85: in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) /usr/local/lib/python3.9/site-packages/django/db/models/query.py:573: in get_or_create return self.get(**kwargs), False ... /usr/local/lib/python3.9/site-packages/django/utils/asyncio.py:26: in inner return func(*args, **kwargs) /usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py:259: in cursor return self._cursor() /usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py:235: in _cursor self.ensure_connection() E RuntimeError: Database access not allowed, use the "django_db" mark, or the "db" or "transactional_db" fixtures to enable it. As you can tell I'm going to be running website tests with these users. Is this a good way to do this? and is this a way to use the pytest.mark.django_db decorator well? -
FAILED SQL Error with Django integration with Mongodb
I have integrated Django with Mongo db using djongo connector. Now If i create a user named "john" from superuser login and add some tasks to john(which is related to our project) . I log out from superuser and login login as user john, then the tasks assigned from super user login will not be visible here and says could not fetch tasks, and in VS code ,it throws backend error as Sub SQL: None FAILED SQL: SELECT COUNT(*) FROM (SELECT DISTINCT "engine_project"."id" AS Col1, "engine_project"."name" AS Col2, "engine_project"."owner_id" AS Col3, "engine_project"."assignee_id" AS Col4, "engine_project"."bug_tracker" AS Col5, "engine_project"."created_date" AS Col6, "engine_project"."updated_date" AS Col7, "engine_project"."status" AS Col8, "engine_project"."training_project_id" AS Col9 FROM "engine_project" LEFT OUTER JOIN "engine_task" ON ("engine_project"."id" = "engine_task"."project_id") LEFT OUTER JOIN "engine_segment" ON ("engine_task"."id" = "engine_segment"."task_id") LEFT OUTER JOIN "engine_job" ON ("engine_segment"."id" = "engine_job"."segment_id") WHERE ("engine_project"."owner_id" = %(0)s OR "engine_project"."assignee_id" = %(1)s OR "engine_task"."owner_id" = %(2)s OR "engine_task"."assignee_id" = %(3)s OR "engine_job"."assignee_id" = %(4)s OR "engine_job"."reviewer_id" = %(5)s)) subquery Params: (6, 6, 6, 6, 6, 6) Version: 1.3.4 Any idea please. -
Email settings queries on Django
I have the following codes in settings.py for email: #SMTP Configuration EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_PORT = 587 EMAIL_USE_TLS = True EMAIL_HOST_USER = '' EMAIL_HOST_PASSWORD = '' I just learnt about this email system from the guide - https://www.youtube.com/watchv=sFPcd6myZrY. In the video, it is stated as not secure as he key in his password but blocked it off. How do I hide this part? From the source code this user post in Github, it is ******** for the user and password. I assume that is his details but it is hidden. How do I do the same for my details?