Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django and apache2(ssl) production setup
I have three web applications currently running in production on Apache2 with SSL. I plan to containerize all of these applications (a Django app) using Docker while continuing to use Apache2 for serving it. Previously, Apache2 ran the Django application with WSGI. how to configure Apache2 (which will also be running in Docker) to work with this Dockerized Django application. I Tried running in manage.py runserver but it is only for development and configured docker ip in apache2 it is running but on production we cannot use that right. -
Model inheritance with existing DB models. Migration issue with “_prt” field
I’ve started to refactor some legacy code and having some difficulties with Model Multi-Table Inheritance on existing model. Let’s say I have a parent class Item: class Item(models.Model): brand = models.CharField(null=True, blank=True) model = models.CharField(null=True, blank=True) category = models.CharField(ItemCategory, null=True, blank=True) I have a child class Phone: class Phone(Item): serial_number = models.CharField() price = models.PositiveIntegerField() For a transition period I’ve allowed Item fields to be null=True and blank=True for a later manual population. However during a migration call I receive it is impossible to add a non-nullable field 'item_ptr' to phone without specifying a default. I understand a nature of this warning as django doesn’t know where to link item_ptr which hides under the hood and links to Item model with OneToOne relation. So I have a dummy Item instance I want to use for linking but how to point the Item id/pk on the console with choosen option 1 as it doesn’t recognize raw int as pk. Is it possible overall or the way is to manipulate with migrations manually? I don't see the option of dropping DB as it's already contains important data. -
Page not found error using django urlconfig
I'm having trouble mapping a page to another page in Django. The app name is Task, and the html files are inside templates\tasks file. the files exist, it's just Django can't find them for some reason! when I just write the path in the browser the pages appear, but when I put the path in the html it gives me page not found error. The settings of the main app settings.py INSTALLED_APPS = [ 'Home', 'Date', 'Task', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] The URLs of the created apps urls.py from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('Home/', include('Home.urls')), path('Date/', include('Date.urls')), path('Task/', include('Task.urls')) ] views.py from django.shortcuts import render taskslist = ["add", "edit", "delete"] # Create your views here. def index(request): return render(request, "tasks/index.html", { "taskslist": taskslist }) def add(request): return render(request, "tasks/add.html") ursl.py from django.urls import path from . import views app_name = "Task" urlpatterns = [ path("", views.index, name="index"), path("add", views.add, name="add") ] index.html {% extends "tasks/layout.html" %} {% block body%} <h1>Tasks</h1> <ul> {% for t in taskslist %} <li><a href="{ url '{{t}}'}">{{t}}</a></li> {% endfor %} </ul> <!-- This part didn't work --> <a href="{% url 'Task:add' %}">Add a task!</a> … -
How to connect Django to SQL Server docker in Mac OS?
I cannot connect Django to SQL Server in mac OS. How to connect Django to SQL Server docker in Mac OS ? Pip Install pip install mssql-django Setting: DATABASES = { 'default': { 'ENGINE': 'sql_server.pyodbc', 'NAME': 'sa', 'HOST': 'localhost', 'PORT': 1433, 'USER': 'SA', 'PASSWORD': 'xxxxx', 'OPTIONS': { 'driver': 'ODBC Driver 13 for SQL Server', }, } } Run python3 manage.py runserver, it display error message as below. is there any way fix that error ? File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django/contrib/auth/models.py", line 94, in <module> class Group(models.Model): File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django/db/models/base.py", line 139, in __new__ new_class.add_to_class(obj_name, obj) File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django/db/models/base.py", line 305, in add_to_class value.contribute_to_class(cls, name) File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django/db/models/fields/related.py", line 1583, in contribute_to_class self.remote_field.through = create_many_to_many_intermediary_model(self, cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django/db/models/fields/related.py", line 1051, in create_many_to_many_intermediary_model 'verbose_name': _('%(from)s-%(to)s relationship') % {'from': from_, 'to': to}, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django/utils/functional.py", line 149, in __mod__ return str(self) % rhs ^^^^^^^^^ File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django/utils/functional.py", line 113, in __text_cast return func(*self.__args, **self.__kw) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django/utils/translation/__init__.py", line 75, in gettext return _trans.gettext(message) ^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django/utils/translation/trans_real.py", line 286, in gettext _default = _default or translation(settings.LANGUAGE_CODE) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django/utils/translation/trans_real.py", line 199, in translation _translations[language] = DjangoTranslation(language) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django/utils/translation/trans_real.py", line 90, in __init__ self._init_translation_catalog() File "/Users/imac/Desktop/Project/Test/myenv/lib/python3.12/site-packages/django/utils/translation/trans_real.py", line 131, in _init_translation_catalog translation = self._new_gnu_trans(localedir) … -
Vue.js Request Returns Empty Array in created Hook, But Works on Button Click
I'm trying to fetch new notifications when my component is created, but the response data is empty. However, when I trigger the same logic with a button click, the API returns the correct data. Here’s part of my Vue.js component: export default { data() { return { showNotification: true, notificationsQueue: [], currentNotification: null, }; }, created() { this.checkForNotifications(); }, methods: { checkForNotifications() { console.log('call hook'); this.$http .get('/notifications/') .then((response) => { console.log('This should succeed from hook', response); console.log('This should succeed from hook', response.data); this.notificationsQueue = response.data; this.showNextNotification(); }) .catch((error) => { console.error('Error captured:', error); }); }, // ... Here’s the output from the console.log() when the request is made in the created hook: This should succeed from hook [{…}]length: 0[[Prototype]]: Array(0) However, when I make the same request by clicking a button, the response data is correct: <button @click="getNotif">Get new notifi</button> getNotif() { this.$http.get('/notifications/').then(response => { console.log('This should succeed', response.data) }) .catch(error => { console.error('Error captured:', error) }) } Here’s the console.log() output from the button click: This should succeed [{…}]0: {id: 2, message: 'test first notification', created_at: '2024-08-29 07:48'}length: 1[[Prototype]]: Array(0) On the Django side, the API seems to work fine: class BusinessNotificationView(APIView): permission_classes = [IsAuthenticated] serializer_class = NotificationSerializer def … -
replace in old project exists Django User model to my User model
I have an old project in which there is a user model that was made by default. Next, we were asked to change the default user model. We have redefined the user model as: class Staff(AbstractUser): # ... new fields ... # no need in model user_permissions = None groups = None class Meta(AbstractUser.Meta): db_table = 'auth_user' swappable = "AUTH_USER_MODEL" Next, we added it to the settings.py file: # user model AUTH_USER_MODEL = 'test.Staff' # django authentication backend AUTHENTICATION_BACKENDS = [ # 'django.contrib.auth.backends.ModelBackend', # Django's default authentication backend 'test.backends.ModelBackend', # Custom authentication backend ] the necessary lines and we can't start the migration (just re-run for tests). ValueError: The field admin.LogEntry.user was declared with a lazy reference to 'test.staff', but app 'test' doesn't provide model 'staff' Please tell me how to properly replace users in django. -
React How to get all free available plugins and tools for CKEditor, similar to Django
In my Django backend, I have all available CKEditor tools and plugins, but in React, I have very few plugins available. See the two screenshots django screenshot react screenshot Why am I not getting all the tools and plugins like I have in Django in my React app? my react config: import { CKEditor } from '@ckeditor/ckeditor5-react'; import ClassicEditor from '@ckeditor/ckeditor5-build-classic'; function CreateBlog() { upload() { return this.loader.file.then((file) => new Promise((resolve, reject) => { const formData = new FormData(); formData.append('upload', file); handleAxois(`${domain}/ckeditor/upload/`, 'post', formData, { headers: { 'Content-Type': 'multipart/form-data' } }) .then((res) => { console.log(res.data); // Debugging: Check the response to ensure the full URL resolve({ default: `${domain}${res.data.url}` // Use the full URL returned from the server }); }) .catch((err) => { reject(err); }); }) ); } abort() {} } return ( <> <CKEditor editor={ClassicEditor} data={subtitle.description} onChange={(event, editor) => { const data = editor.getData(); handleSubtitleChange(index, subtitleIndex, 'description', data); }} config={{ extraPlugins: [CustomUploadAdapterPlugin], mediaEmbed: { previewsInData: true }, filebrowserUploadUrl: '/ckeditor/upload/', filebrowserImageUploadUrl: '/ckeditor/upload/', height: 500, }} /> </> } -
When does Djangos CONN_MAX_AGE get checked/used?
I recently had a "Too many connections" issues of my Django+Celery application with a Postgres DB on Heroku. Could dyno restarts be the issue? The idea is that the dyno restart drops the connection, but Postgres keeps them. Setting CONN_MAX_AGE seems to have solved the issue, but I'm uncertain. The question now is: How does CONN_MAX_AGE work? (1) Does Django actively check the age of the connection and close + restart it when it's too old or (2) Is CONN_MAX_AGE a parameter of the connection itself, so that postgres automatically closes the connection after that time? -
MySQL Authentication Plugin Issues on macOS
I’m working on a blog project using Python and Flask, and I’m using the MySQL database from XAMPP for user registration. The project worked perfectly on my Windows machine, but after switching to macOS, I’ve been encountering various issues with the registration process. I’ve managed to resolve most of the issues, but I’m still struggling with one particular error. I’ve been working on this for a week now and could use some help. Error Details: MySQLdb.OperationalError: (2059, "Authentication plugin 'mysql_native_password' cannot be loaded: dlopen(/opt/homebrew/Cellar/mysql/9.0.1/lib/plugin/mysql_native_password.so, 0x0002): tried: '/opt/homebrew/Cellar/mysql/9.0.1/lib/plugin/mysql_native_password.so' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/mysql/9.0.1/lib/plugin/mysql_native_password.so' (no such file), '/opt/homebrew/Cellar/mysql/9.0.1/lib/plugin/mysql_native_password.so' (no such file)") enter image description here Context: • The application is running on macOS using XAMPP. • The database is configured correctly, and I can connect to it using other tools. • I’ve tried various solutions like asking chatgpt or searching on google Has anyone encountered this issue or have any suggestions on how to resolve it? Thanks in advance for your help! -
Should authentication_classes and permission_classes in Django's APIView Be Defined with Lists or Tuples?
I'm trying to understand the best practice for setting authentication_classes and permission_classes in Django's APIView. Specifically, I’ve seen both tuples and lists being used to define these attributes: Using a tuple: class Home(APIView): authentication_classes = (JWTAuthentication,) permission_classes = (permissions.IsAuthenticated,) Using a list: class Home(APIView): authentication_classes = [JWTAuthentication] permission_classes = [permissions.IsAuthenticated] Both approaches seem to work correctly, but I'm unsure if there are any specific reasons to prefer one over the other. Should I use a list or a tuple in this scenario? Are there any implications for using one over the other in terms of performance, readability, or following Django's best practices? I tried using both tuples and lists for authentication_classes and permission_classes in Django’s APIView. Both work fine, but I’m unsure which one is better or recommended. I was expecting to find clear guidance on this. -
Whats the difference between asyncio and multithreading in python?
Multi-threading import threading def heavy_computation(): # A CPU-bound task result = sum(x * x for x in range(10**6)) threads = [] for _ in range(4): t = threading.Thread(target=heavy_computation) threads.append(t) t.start() for t in threads: t.join() Asynchronous python import asyncio # Define an asynchronous function (coroutine) async def async_task(name, duration): print(f"Task {name} started, will take {duration} seconds.") await asyncio.sleep(duration) # Simulate a long-running I/O-bound task print(f"Task {name} finished.") # Define the main coroutine async def main(): # Create multiple tasks using asyncio.create_task() task1 = asyncio.create_task(async_task("A", 2)) task2 = asyncio.create_task(async_task("B", 3)) task3 = asyncio.create_task(async_task("C", 1)) # Wait for all tasks to complete await task1 await task2 await task3 # Run the main coroutine asyncio.run(main()) What are the differences between using multi-threading in Python and Asynchronous Python since the global interpreter lock prevents parallelism of threads, only a single thread can execute at one time. Asynchronous Python is also also single threaded. I suppose, it could the resource management of multi-threads which could make asynchronous python more efficient. Which is preferred for backend applications like Django? Googled but no answers -
Python Django getting a TemplateDoesNotExist at / when deploying site to PythonAnywhere [closed]
enter image description here I keep getting this error message when trying to deploy my site on pythonanywhere's site. When I try it locally, it works without any issue. I am just wondering why the path is not working now. I have tried many different paths and they all seem to not work. Wondering if anyone has seen this before? Trying to deploy to site, and it did not go through. -
Django login_required redirect to login page even when user is authenticated
I setup login_required in my app to limit access to pages to logged users. It works fine locally, if user is authenticated, he has access to the page and if not, he will be asked to enter his credentials. The problem is, in production, even when the user is authenticated, he will be redirected to the login page. Any idea how can I resolve this issue ? Thanks! I removed login_required and tried the raw way which is using the if statement if not request.user.is_authenticated: return redirect(f"{settings.LOGIN_URL}?next={request.path}") But I still have the same issue. I need the user once logged into the app to be able to go to other pages without asking for login again as it works locally. -
How to Implement JWT Authentication with a Dynamic Database in Django? (User table is in each database its not central)
I'm working on a Django application where the user data is not stored in a central database. Instead, each client has their own separate database hosted on their own server. Here's the setup: JWT Authentication is used for the app. The central Django server handles authentication requests but must dynamically connect to a client's specific database based on information provided in the JWT token. The employee_id is stored in each client's database, not in the central Django database. The connection string to the client's database is included in the JWT token payload. My Implementation: I've created a custom JWTAuthentication class where: Token Validation: The JWT token is validated. Database Connection: Based on the token payload, I dynamically connect to the client's database using the connection string provided in the token. User Verification: I fetch the user from the client’s database using the employee_id in the token and check if the user is active. Here's a simplified version of my JWTAuthentication class: from rest_framework import authentication from rest_framework.request import Request from .models import TokenUser from .settings import api_settings from .tokens import Token from .exceptions import AuthenticationFailed, InvalidToken import pymssql class JWTAuthentication(authentication.BaseAuthentication): def authenticate(self, request: Request): header = self.get_header(request) if header is … -
React + Django full stack webdev
recently or maybe like year ago I started to learn everything that I need to know to be fullstack web developer (html,css,js,react..). Now I am trying to build a fullstack website as my first big project. I learned a lot of things about how to built it and now I´ve come to conclusion that I want to use react with django. **Little information about my website: it will consist of many pages like: ** HOME page, NEWS page where I want to display news about certain topics so I need to call API and Fetch data from websites, LEARN page where anyone can find information about certain topic that this website is based on, CHAT ROOM which is almost like mini Discord clone where anyone can talk to anyone in chat rooms they created and can modify them etc... FAQ and SUPPORT pages which are basically feedback from people to me, I might combine them to one page idk I am not sure right now, and of course PROFILE page for every user. My question is, is this a good combination for my website? I know that as a developer I should programm in language I want or I like … -
Django Admin Keeps Failing
I recently created a new Django project using cookie cutter with docker. I use this regularly to setup my Django projects but recently I've had an issue where any new project I start will boot up and load correctly but for some reason the admin says page not found. I can login with my created super user and stay on the root /admin dashboard but when I try to click on any of the table links it automatically goes to a page not found. Has anyone else experienced this and if so how have you fixed this? All of the normal django functions ie. migrate, makemigrations... are working fine. I just can't view anything in the admin. Could this be a docker issue? I've checked the logs in docker but haven't noticed anything important. -
Django Context getting lost in email
I am trying to send a forgot password email in Django. Although even after using print debug statements to make sure that the slug is available in my context, it's keeps throwing an error. My models.py: class Restaurant(models.Model): name = models.CharField(max_length=100) email = models.EmailField() description = models.TextField() landing_page_tagline = models.TextField() landing_page_image = models.ImageField(upload_to='restaurant_images/') address = models.CharField(max_length=255, null=True) phone = models.CharField(max_length=20, null=True) logo_image = models.ImageField(upload_to='restaurant_images/') primary_color = models.CharField(max_length=7) # Hex color code favicon = models.FileField(upload_to='restaurant_favicons/', null=True, blank=True) about_us_image1 = models.ImageField(upload_to='restaurant_images/') about_us_text1 = models.TextField(blank=True, null=True) about_us_image2 = models.ImageField(upload_to='restaurant_images/') about_us_text2 = models.TextField(blank=True, null=True) about_us_image3 = models.ImageField(upload_to='restaurant_images/') about_us_text3 = models.TextField(blank=True, null=True) contact_us_image = models.ImageField(upload_to='restaurant_images/') map_iframe_src = models.TextField(blank=True, null=True) footer_text = models.TextField() facebook_link = models.URLField(null=True, blank=True) instagram_link = models.URLField(null=True, blank=True) youtube_link = models.URLField(null=True, blank=True) twitter_link = models.URLField(null=True, blank=True) slug = models.SlugField(unique=True, max_length=100, null=True) stripe_subscription_id = models.CharField(max_length=255, blank=True, null=True) def save(self, *args, **kwargs): if not self.slug: self.slug = slugify(self.name) super().save(*args, **kwargs) def __str__(self): return self.name class RestaurantUser(AbstractUser): restaurant = models.OneToOneField('Restaurant', on_delete=models.CASCADE, null=True, blank=True) phone = models.CharField(max_length=20, blank=True, null=True) is_restaurant_admin = models.BooleanField(default=False) groups = models.ManyToManyField( Group, related_name='restaurantuser_set', blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_query_name='restaurantuser', ) user_permissions = models.ManyToManyField( Permission, related_name='restaurantuser_set', blank=True, help_text='Specific permissions for … -
Django Admin: Custom bulk duplication action not processing form data correctly
Title: Django Admin: Custom bulk duplication action not processing form data correctly Description: I'm trying to implement a custom action in Django Admin to duplicate records in bulk for a model. The process should work as follows: Select multiple records in the Django Admin. Click on a custom action called "Duplicate selected records in bulk". A screen appears where the user can enter new effective dates (start and end). Upon clicking "Duplicate", new records are created, copying all fields from the original record except the effective dates, which are updated as entered by the user, and the liberado field, which should be set to False. The issue I'm facing is that when I submit the form with the new dates, the duplication view does not seem to process the submitted data. The POST method is not being triggered correctly, and the form data is not captured. When sending the created custom form, the request is not even falling into the view. The print which I placed is not being fired. Here is the relevant code structure: Model and Form: class OrcamentoOpicional(models.Model): nome = models.CharField(max_length=100) categoria = models.ForeignKey(CategoriaOpcionais, on_delete=models.DO_NOTHING, null=True, blank=True) sub_categoria = models.ForeignKey(SubcategoriaOpcionais, on_delete=models.DO_NOTHING, null=True, blank=True) descricao = models.TextField() valor … -
How do we unzip a zip file in the file's parent folder in python3.x
I have a requirement to unzip an archive by selecting it at runtime. I am passing the zip file using HTML input type file in my template and then using ZipFile's function extractall(). This rudimentary arrangement is working, however the unzipped contents are getting saved in the (Django) project's root folder. I can control where the extracted files get stored by using the path option, which I feel would be a little limiting in the sense that in that case, the folder path will have to be hardcoded. (There are other means of supplying the path information at runtime, but still user intervention would be required.) The file being an inmemory file, I know the path information will not be available, which otherwise would have been handy. Is there a way I may save the unzipped file to the same folder as the zipped file is selected from? Thanks a bucnh. -
How to ignore `ModuleNotFoundError` when using mypy for github actions?
I’m integrating mypy into my GitHub Actions workflow to check only the changed files in my django project: name: Pull Request Backend Lint and Format on: [push, pull_request] jobs: backend-lint-and-check: runs-on: ubuntu-latest defaults: run: working-directory: backend steps: - uses: actions/checkout@v3 with: fetch-depth: 0 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install dependencies run: | python -m pip install --upgrade pip pip install ruff mypy mypy-extensions django-stubs django-stubs-ext - name: Get changed files id: changed-files run: | if [ "${{ github.event_name }}" == "pull_request" ]; then BASE_SHA=${{ github.event.pull_request.base.sha }} else BASE_SHA=$(git rev-parse HEAD^) fi CHANGED_FILES=$(git diff --name-only --diff-filter=d $BASE_SHA...HEAD | grep '^backend/' | sed 's|^backend/||' | grep '\.py$' | tr '\n' ' ') echo "files<<EOF" >> $GITHUB_OUTPUT echo "$CHANGED_FILES" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT - name: Run Ruff check if: steps.changed-files.outputs.files run: | FILES="${{ steps.changed-files.outputs.files }}" if [ ! -z "$FILES" ]; then echo "Running Ruff check on files:" echo "$FILES" for file in $FILES; do ruff check "$file" || echo "Ruff check found issues in $file" done else echo "No Python files to check" fi - name: Run Ruff format check if: steps.changed-files.outputs.files run: | FILES="${{ steps.changed-files.outputs.files }}" if [ ! -z "$FILES" ]; … -
Windows 11 Home - Unable to run django-admin
I have looked through several post regarding either: django-admin : The term 'django-admin' is not recognized or [Errno 2] No such file or directory I am trying to run django-admin startproject...and again I have tried it several ways and keep getting one of the two above errors. I've used the full path to python, I have used variations of that command that I have seen in several post but none are working. I am able to run "python -m django --version" and I get 5.1. I can run a .py file in the terminal window fine. But can't use "django-admin". Here is one of the full errors: C:\Users\Famil\AppData\Local\Microsoft\WindowsApps\python.exe: can't open file 'C:\Alejandro\Django\django-admin.py': [Errno 2] No such file or directory Please advise, this is so crazy. Cheers -
Increase security when sharing images between two parties
I'm building a system that have two types of users: doctor and patient. Just to give context. A doctor is allowed to save medical records (images) for any patient, and this images are going to be saved as encrypted blobs on a MySQL DB. The doctor is also able to request a temporal access to a certain patient medical record (group of images) (here i'm using a magic link). The patient is just able to see their own records, and accept or deny access requests to see his own medical history from an specific doctor. After given all this context, the challenge i'm facing is that I'm trying to find a way to encrypt all the images for the same patient with certain "secret phrase" that the patient should be already entered before. But this phrase cannot be stored on the database for security reasons. So the thing is that this phrase it al should be available on the doctor session when its loading a record for a patient to encrypt the file, or maybe that could be done on another way that i'm not seeing. Any ideas? I'm using Django framework and I'm not working with Django Rest, just … -
Django: Use widgets in Form's init method?
Why the widget for the field defined as a class attribute is working, but it is not for the instance attribute inside the __init__ method? (I need the init method) class CropForm(forms.ModelForm): class Meta: model = CropModel fields = ['name', 'label'] label = forms.CharField(label='label', widget=forms.TextInput(attrs={'class': 'input'})) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.name = forms.CharField(label='name', widget=forms.TextInput(attrs={'class': 'input'})) How do I get the widget in the __init__ method to work? Thanks. -
How do i access my pysimplegui program online?
I made a program using Pysimplegui, but I want to access it over the internet. I found pysimpleguiweb which looked promising, except it looks like it is still version 0.39, so it isn't finished? I would like to know where instructions are for this. The below is a website which looks like someone is still working on it as of two weeks ago, but it also looks like they're asking for payment. https://github.com/PySimpleGUI/PySimpleGUI/issues/142 Below may be the answer, it looks like they're creating a pysimplgui and then using flask to show it over the internet. Will Django do the same thing? I can't find much on the internet about django and pysimplegui, or flask and pysimplegui. how to send data from separate computer to flask app Is there a way to access my pysimplegui program over the internet? -
How can I mark an email as verified in django-allauth?
I'm setting up a website from scrath that has been coded with Django and django-allauth. To create a new superuser from scratch, I need to run this command: python manage.py createsuperuser When I try to log in as this user on the website, I see this message: Verify Your Email Address We have sent an email to you for verification. Follow the link provided to finalize the signup process. If you do not see the verification email in your main inbox, check your spam folder. Please contact us if you do not receive the verification email within a few minutes. Let's say that I entered a fake email address or that the website doesn't have working SMTP yet. How do I mark the email address of this user as verified, either from the command-line, or in Python?