Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django rest framework and swagger : invalid literal for int() with base 10: 'None'
When I use rest_framework_swagger, I face some errors. as you can see it's more about library and port. is there something wrong about my other views? how can i fix it? here is my code : from rest_framework_swagger.views import get_swagger_view from . import views schema_view = get_swagger_view(title='Pastebin API') urlpatterns = [ path('', schema_view), ] and I face this is error which is about type of port which is none: Traceback (most recent call last): File "/home/alireza/anaconda3/lib/python3.7/site-packages/asgiref/sync.py", line 482, in thread_handler File "/home/alireza/anaconda3/lib/python3.7/site-packages/django_elasticsearch_dsl_drf/viewsets.py", line 160, in __init__ self.document._get_using() File "/home/alireza/anaconda3/lib/python3.7/site-packages/elasticsearch_dsl/connections.py", line 109, in get_connection return self.create_connection(alias, **self._kwargs[alias]) File "/home/alireza/anaconda3/lib/python3.7/site-packages/elasticsearch_dsl/connections.py", line 84, in create_connection conn = self._conns[alias] = Elasticsearch(**kwargs) File "/home/alireza/anaconda3/lib/python3.7/site-packages/elasticsearch/client/__init__.py", line 203, in __init__ self.transport = transport_class(_normalize_hosts(hosts), **kwargs) File "/home/alireza/anaconda3/lib/python3.7/site-packages/elasticsearch/client/utils.py", line 52, in _normalize_hosts if parsed_url.port: File "/home/alireza/anaconda3/lib/python3.7/urllib/parse.py", line 169, in port port = int(port, 10) Exception Type: ValueError at /swagger/ Exception Value: invalid literal for int() with base 10: 'None' ```. can you help me? -
Django template websocket URL tag
I am trying to load ws_urlpatterns to template with tags: routing.py from django.urls import path from .consumers import WSConsumer ws_urlpatterns = [ path('ws/some_url/', WSConsumer.as_asgi(), name="ws"), ] <div class="container"> <div class="row"> <div class="col-6 mx-auto mt-5"> <h1>{{ text }}</h1> </div> </div> </div> <script> let socket = new WebSocket('ws://localhost:8000/ws/some_url/'); const h1 = document.querySelector('h1'); socket.onmessage = function(event){ let data = JSON.parse(event.data); h1.innerText = data.message; } </script> I tried let socket = new WebSocket("{% url 'ws' %}"); but I got Reverse for 'ws' not found. 'ws' is not a valid view function or pattern name. I am new to Django channels, will be very glad if you can give me a hand. -
How interdependent db calls handled in transaction.atomic
I have two DB calls inside the transaction.atomic() Sample codes with transaction.atomic(): result1, created = SomeModel.objects.get_or_create(**somedata) if not created: flag = SomeOtherModel.objects.filter(somemodel=result1).exists() if flag: result1.some_attr = value1 if flag else value2 result1.save() AFAIK about the transaction.atomic when my python codes do not cause an exception, so all the DB calls will be committed on the database. If any of the exceptions raised inside the block, no database operation will be committed to the database. So how is this thing handled when the DB call of one is used in the python logic to make other DB operations? Didn't find this species in the documentation, if any good source, please mention it. -
How to integrate machine learning model with Django website
I am new to Django and machine learning models. I am trying to build a simple recommendation system using item-based collaborative filtering. Where there will be a search bar where you search for a userid, it will query the database for that user and display recommendations for that user. I created a model using KNN in jupyter notebook. However, I don't know how to integrate the model with my website. Furthermore, I don't know how to connect my search input to the model and get recommendations for the searched userid. This is what I did so far. Any help would be appreciated immensely. My views.py def search_user(request): if request.method == "POST": searched = request.POST['searched'] search_result = Ratings.objects.filter(Q(UserID__name__icontains=searched)) return render(request, 'admin_panel.html', {'searched': searched}, {'search_result': search_result}) else: return render(request, 'admin_panel.html', {}) def get_recommendation(request): num_ratings = Ratings.objects.count() all_user_names = list(map(lambda x: x.UserID, Ratings.objects.only("UserID"))) all_product_ids = set(map(lambda x: x.Product_ID, Ratings.objects.only("Product_ID"))) num_users = len(list(all_user_names)) # create sparse matrix productRatings_m = sp.sparse.dok_matrix((num_users, max(all_product_ids) + 1), dtype=np.float32) for i in range(num_users): # each user corresponds to a row user_ratings = Ratings.objects.filter(UserID=all_user_names[i]) for user_rating in user_ratings: productRatings_m[i, user_rating.Product_ID] = user_rating.rating productRatings = productRatings_m.transpose() # create pivot table coo = productRatings.tocoo(copy=False) df = pd.DataFrame({'Product_ID': coo.row, 'UserID': coo.col, 'rating': coo.data}) … -
Django display images from local resource
In case I'm: at a very early stage of developing; using Chrome, which doesn't allow images from local resource, and storing my images in a local /static folder, what could be the best workaround for displaying images, other than through the {% static %} tag? I have been using {% load static %}...{% static variable/path %} in my templates, but now I'm trying to display images in the admin page, which requires a good deal of overriding, and admin templates aren't easy to find where exactly to override. Lately I tried format_html, as in: from django.contrib import admin (...) @admin.display(description='Foto') def show_foto(self): return format_html( '<img src=https://media.(...)>' ) Which works fine as long as the image resource isn't local. Also, Django tags don't seem to work inside format_html(). -
Django Unit tests can't ovveride variable from tessting when post
I need a test for update view. My update view creates folders. For tests I want to change path of the folders. I tried to change settings with override_settings decorator and with with self.settings(): statment from https://docs.djangoproject.com/en/2.2/topics/testing/tools/#django.test.modify_settings But when I run post in my test the folders are created according to settings of my project not test settings. The path for creating the folders in my settings is saving in variable CERTIFICATION_WORKS_ROOT. In my view I import it as from django.conf import settings and then output_path = settings.CERTIFICATION_WORKS_ROOT. For debugging I added in view print(f'output_path in view - {output_path}'), and in my test print(f'test settings - {settings.CERTIFICATION_WORKS_ROOT}'). Here is my test module: from datetime import date import os from django.test import TestCase, Client, override_settings from django.urls import reverse from django.contrib.auth.models import User from django.core.files.images import ImageFile from case.models import * TEST_WORKS_ROOT = os.path.join('/home/oleh/Documents/test_output/') @override_settings(CERTIFICATION_WORKS_ROOT=TEST_WORKS_ROOT) class TestCases(TestCase): fixtures = ['cases_test_data.json'] def setUp(self): body1 = Body.objects.get(name='body_one') body1.logo.save('uploads/logo-UC.svg', ImageFile(open('/home/oleh/Downloads/logo-UC.svg', 'rb'), 'logo-UC')) self.client = Client() # remember url to case list page self.url = reverse('update_case', kwargs={'pk': 1}) #self.url = reverse('cases') def test_form(self): user = User.objects.get(id=1) self.client.force_login(user) response = self.client.get(self.url) #print(response.url) self.assertEqual(response.status_code, 200) self.assertContains(response, 'ЗМІНИТИ СПРАВУ') self.assertContains(response, 'Додати роботу') self.assertContains(response, 'Друк') self.assertContains(response, 'Тип договору') self.assertContains(response, … -
How to regroup result by fields?
I need to do a "stats" view on some products sold. Unfortunately, I get lost with annotate, aggregate, I can't get the desired result. I have 2 models: class SaleProduct(models.Model): name = models.CharField(_('Name'), max_length=80) price = models.FloatField(_('price')) unit = models.CharField(_("unit"), max_length=20, default="€") tva = models.FloatField(_('tva')) dlc = models.DateField('dlc') class Sale(models.Model): products = models.ManyToManyField( "sale.SaleProduct", related_name="sale_saleproducts", verbose_name=_("Products"), blank=True ) paiement_method = models.CharField(_("paiement method"), max_length=255) sale_ok = models.BooleanField(_("status"), default=True) total = models.FloatField(_("Total")) I have a table of values with 6 columns: Total Total quantity Name (of product) DLC Total per DLC Total quantity per DLC First thing I can't do: group the products by name and DLC. Indeed, each line of the table must correspond to a product with a name and a unique DLC. Once this query is correctly filtered, the first column calculates the sum of the price of the products that have the same name regardless of the DLC. The second column is the count of the products that have the same name whatever the DLC. The 3rd column is the name of the product. The 4th column is the DLC The 5th column is the sum of the price of the products that have the same name and … -
The model objects from django admin aren't connected to the backend model objects
So I'm using a $5 digital ocean droplet using ubuntu and nginix to host a django website, I followed along this this tutorial and this guide. So a part of the guide said to run gunicorn --bind 0.0.0.0:8000 myproject.wsgi from the virtual env, it worked and as a test I created a highlights object to see if it would show, it did and this is what it looked like: After which I added a gunicorn socket and completed the article till the point where it told me to run sudo ufw allow 'Nginx Full', however after I ran it, first of all, the css for the admin page was gone but the bigger concern was that after I added a few extra objects from the admin panel the changes didn't seem to be noticed by my views.py as when I displayed the contents of Highlights.objects.all() it only showed the one from above. But the admin page does show that the objects had been successfully added. Also the github repo's media folder didn't show any of the new images in them including the one uploaded from gunicorn --bind 0.0.0.0:8000 myproject.wsgi they only had the images I uploaded while in local development … -
Django siteframework, How often django create sitemap.xml file?
I have a Django siteframework to create dynamic sitemap.xml sheet. class NewsSitemap(Sitemap): changefreq = "daily" priority = 0.8 protocol = 'https' def items(self): return News.objects.all() # news objects def lastmod(self, obj): return obj.date_posted def Newstitle(self, obj): return obj.titleEnglish def location(self,obj): return '/news/'+ obj.country + '/' +obj.slug will server create sitemap file only once in a day according to above code ? If server create sitemap file each time when different user visit , it would take lot of processing power as my database is huge. -
How can we use two different serializers in a single generics.ListAPIView while overriding get_queryset() method
My Views.py class RelatedFacultyProfile(generics.ListAPIView): serializer_class = FacultyProfileGenericSerializer permission_classes = [IsAuthenticated] def get_queryset(self): helper = UserTypeHelper(self.request, path=False) if helper.user_type == 'F': queryset = Faculty.objects.filter(department=self.request.user.faculty.department) if helper.user_type == 'S': queryset = Faculty.objects.filter(department=self.request.user.student.branch) return queryset class RelatedStudentProfile(generics.ListAPIView): serializer_class = StudentProfileGenericSerializer permission_classes = [IsAuthenticated] def get_queryset(self): helper = UserTypeHelper(self.request, path=False) if helper.user_type == 'F': queryset = Student.objects.filter(branch=self.request.user.faculty.department) if helper.user_type == 'S': queryset = Student.objects.filter(branch=self.request.user.student.branch) return queryset I want to combine the querysets of these two views to generate a single JSON response which will require two different serializers So how to achieve this ? -
Function in python generate str lik that QW300
How i can write funtion in python generate sting like that "QW300" and the next string of that function QW310 -
Nested unique data entry Django rest API
I have two view-set one named as Menu and other user.The user contain a filed name as items which has nested data { "id": 30, "email": "loop@loop.com", "name": "loop", "items": [ { "id": 171, "item_name": "burger", "cost": 343 "menu": 30 } ] }, { "id": 31, "email": "as@com.com", "name": "ak", "items": [ { "id": 180, "item_name": "burger", "cost": 343, "menu": 31 }, { "id": 182, "item_name": "burger", "cost": 343, "menu": 31 } ] } Problem Now my question is how can I have only unique data in every specific user like different users can have same item_name but a single user can't have the same item_name Eg: user with name loop has an item_name : burge and also the user with name ak has an item_name : burger this case can exists but a single user can't have multiple item with the same name like ak has burger multiple time so is there any way to avoid repeated data entry in every specific user if any of the file is required pls let me know i will attach it over hear Thank You:) -
API request should take User Object as input and update the user
The task is to create an API endpoint “/updateUser” for updating the user information. The API request should take the User object as input and update the user. My model is this: class UserModel(AbstractUser): name = models.CharField(max_length=50) email = models.EmailField(max_length=50, unique=True, primary_key=True) phone = models.CharField(max_length=10, unique=True) gender = models.CharField(max_length=10, null=True) dob = models.DateField(null=True) username = models.CharField(max_length=50, unique=True) REQUIRED_FIELDS = [] Serializer is: class UserSerializer(serializers.ModelSerializer): class Meta: model = UserModel fields = ['id','name','username','email','phone','password'] extra_kwargs = { 'password': {'write_only': True} } def create(self, validated_data): password = validated_data.pop('password', None) instance = self.Meta.model(**validated_data) if password !=None: instance.set_password(password) instance.save() return instance url is: from django.urls import path from . views import RegisterView, UpdateUserView urlpatterns = [ path('register/', RegisterView.as_view()), path('updateUser/', UpdateUserView.as_view()) ] Now, how to create view for this which takes object as input and update it?! -
Click on a button and start Time counting on redirected page (JavaScript)
I am trying to develop a quiz app with Django. Where I want to add a functionality like this - "When the users will click on start test button, they will be redirected to the questions page, and exam time will be started". Here I am using JavaScript "setInterval" to count time. It's working on the same page, but it's not working on the redirected page. My Js code : var check = null; function printDuration() { if (check == null) { var cnt = 0; check = setInterval(function () { cnt += 1; document.getElementById("para").innerHTML = cnt; }, 1000); } } function stop() { clearInterval(check); check = null; document.getElementById("para").innerHTML = '0'; } console.log("Time counting... ... ...") Button <a href="{% url 'test' %}" class="btn btn-primary mt-5"id="btnStart" type="button" value="Start" onclick="printDuration();">Start Test</a> Redirected page code: , here time counting will be started: <h2 class="pb-5">Welcome to test page</h2> <p id="para">0</p> -
Error while exporting excel file using Django and xlwt
Working with the xlwt library for exporting Excel docs using the Django framework, the following problem appeared: invalid literal for int() with base 10: 'Name of product' I tried to use different conversions in data types, but it didn't help. I would like to know how to solve this problem, thank you for any advice. models.py: class Product(models.Model): name = models.CharField(max_length=100, null=True) quantity = models.PositiveIntegerField(null=True) category = models.CharField(max_length=50, choices=CATEGORY, null=True) def __str__(self): return f'{self.name}' views.py: def export_excel(request): response=HttpResponse(content_type='application/ms-excel') response['Content-Disposition'] = 'attachment: filename=Expenses' + \ str(datetime.datetime.now())+'.xls' wb = xlwt.Workbook(encoding='utf-8') ws = wb.add_sheet('Expenses') row_num = 0 font_style = xlwt.XFStyle() font_style.font.bold = True columns= ['Name of product', 'Category', 'Quantity'] for col_num in range(len(columns)): ws.write(row_num, columns[col_num], font_style) font_style = xlwt.XFStyle() rows = Product.objects.filter(owner=request.user).values_list( 'name', 'quantity', 'category') for row in rows: row_num += 1 for col_num in range(len(row)): ws.write(row_num, str(row[col_num]), font_style) wb.save(response) return response -
How to update image fields using Django forms
I am attempting to create a blogging application and in it I have 2 forms, one for editing pre-existing posts, and the other for creating them. However, I am unable to get updated images, when the edit form is submitted. All textual data goes through... Models.py: class Post(models.Model): title = models.CharField(max_length=200, unique=True) slug = models.SlugField(max_length=200, unique=True) author = models.ForeignKey(User, on_delete=models.CASCADE, related_name= 'blog_posts') short_description = models.TextField() updated_on = models.DateTimeField(auto_now=True) content = RichTextUploadingField() created_on = models.DateTimeField(auto_now=True) status = models.IntegerField(choices=Status, default=0) cover_image = models.ImageField(upload_to = 'coverimages', null =True, blank = True) captioned_image = models.ImageField(upload_to = 'captionedimages', null=True, blank = True) caption = models.CharField(max_length=300) featured = models.IntegerField(choices=Featured, default=1) category = models.ForeignKey(PostCategory, on_delete=models.CASCADE, null=True, blank=True) embedded_code = models.TextField(blank=True, null=True, default='null') tags = models.ManyToManyField(Tag, blank=True) class Meta: ordering = ['-created_on'] def __str__(self): return self.title forms.py: class EditForm(forms.Form): title = forms.CharField(max_length=100, label='Post Title') short_description = forms.CharField(widget=forms.Textarea(attrs={"rows":3, "cols":100})) content = forms.CharField(widget=CKEditorUploadingWidget()) status = forms.NullBooleanField(label='Ready to Publish?') image = forms.ImageField(label='Select a cover image:', required=False) captioned_image = forms.ImageField(label='Select a captionable image:', required=False) caption = forms.CharField(max_length=200) try: category = forms.ModelChoiceField(queryset=PostCategory.objects.all()) except: category = forms.ChoiceField(choices= ('default')) embed = forms.CharField(widget=forms.Textarea(attrs={"rows":3, "cols":100})) tags = forms.CharField(widget=forms.Textarea(attrs = {"rows":1, "cols":150})) editpost.html: {% load widget_tweaks %} <form action="" method="POST" enctype="multipart/form-data"> {% csrf_token %} {{ form.media }} <legend>Edit … -
How to save updated text input in django?
I'm new to django and want to create a to do site. I currently am able to add a new task and show all the tasks in one page (the tasks are in text inputs). However, I am unable to figure out how to change and save the text input. I would like to be able to change the text in the text input and somehow save it without having to go to another page (ex: press an edit button that goes to a new url to edit and save the text). Views.py class TaskCreate(CreateView): model = Task fields = ['user', 'title'] template_name = 'todo_list/task_list.html' success_url = reverse_lazy('tasks') def get_context_data(self, **kwargs): list = super(TaskCreate, self).get_context_data(**kwargs) list["tasks"] = self.model.objects.all() return list task_list.html <html> <h1>Today</h1> <form method="POST"> {% csrf_token %} {{form.as_p}} <input type='submit'/> </form> <table> {% for task in tasks %} <tr> <td> <input type="text" name="task-value" value="{{task.title}}"> </td> </tr> {% empty %} <h3>No tasks for today</h3> {% endfor %} </table> </html> Models.py class Task(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True) title = models.CharField(max_length=200) complete = models.BooleanField(default=False) created = models.DateTimeField(auto_now_add=True) def __str__(self): return self.title class Meta: ordering = ['complete'] -
How to make a verification in an argument passed to a periodic task in django celery beat
I have a periodic task in django celery beat, which needs an argument (an IP address) to be given in the django admin. What I need to do is to check if that argument is correct once I save the periodic task. If it is, save it normally. If it isn't raise some kind of error. I tried to import the PeriodicTask model and edit the save function like this (I did this in celery.py): from django_celery_beat.models import PeriodicTask def save(self, *args, **kwargs): #code to check if the arg is correct #if incorrect, raise error else super(PeriodicTask, self).save(*args, **kwargs) But that didn't work. Any ideas? -
Why should i use separate table for maintain roles?
Am creating a project which has multiple roles, so initially i thought of adding a Colum named "role" in user table and maintain the roles. But later on i got a requirement like to add staffs under each role. Lets say Agent & Institution are two primary roles. And agent and Institution may contain one or more staffs under them and those staff has many categories like admin staff or sales staff etc. ( this categories will be maintained by groups & permissions of Django ). So to differentiate the categories of the staff i thought of adding extra roles like "admin_staff" or "sales_staff" but i think its not scalable ? And so again i thought of creating a roles table to maintain this. Am bit confused on how to handle this situation I have two apprroaches : Approach 1 : Now my user table has these, Class User: name, email, ..... role And thought of adding a extra field named: "role_name" and make "role" as numeric and then keep track the categories of staff using the role_name example: role == 1 // agent and role_name == "admin_staff" And my second approach: create a new role table and have extra … -
Django: NOT NULL constraint failed: appname_post.user_id
I have the following django rest framework serializer and view for a model Post, and the models defined for the app are as following. Now I wanted to test the API, so tried to "create" a new post from the API page, but then I got an error IntegrityError at /api/posts/ NOT NULL constraint failed: appname_post.user_id. So then I tried to debug and checked its request.data value, it says it only has title and content but not user_id, as I could expect from the error above. But now I have no idea how to tell the API automatically relate the user_id field to request.user.id. Isn't not enough to just add the user_id = serializers.ReadOnlyField(source='user.id') line? I could do "retrieve", "update", "patch" etc but just cannot "post" (create). Thanks for your help. serializer and view class DevPerm(permissions.BasePermission): def has_object_permission(self, request, view, obj): return True def has_permission(self, request, view): return True class PostSerializer(serializers.HyperlinkedModelSerializer): user_id = serializers.ReadOnlyField(source='user.id') class Meta: model = Post fields = ('url', 'id', 'title', 'content', 'created_at', 'voters', 'comments', 'user_id', ) read_only_fields = ( 'id', 'created_at', "voters", "comments", # "user_id", ) class PostViewSet(viewsets.ModelViewSet): queryset = Post.objects.all() serializer_class = PostSerializer permission_classes = [permissions.IsAuthenticated, DevPerm,] models class Post(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='posts', … -
Saving the time in Django and running tasks later
I have a Django website where I store some data and will have to have certain tasks performed at a specific time. I've done this before with model that looked like this: start_at = models.DateTimeField(...) and when user created an object the current time would be deducted from the start_at and sent off to django background-tasks with schedule being the difference in seconds (done with datetime and pytz because of timezones). Now I'm curious about having something like start_at = models.FloatField(...) And here I would store the the value that I get from user (turned into unix time) and schedule it pretty much the same just without worrying about timezones and just doing the start_at - current_time for schedule. Now, in my opinion this could help me with displaying the different timezones to different users easier and the whole scheduling part is much simpler, but I'm not sure how practical it is, if there are some limitations or something that I'm not familiar with. The second this would be scheduling it with something like django background-tasks which I'm familiar with or maybe Celery but I don't know too much about it and I'm not sure how the whole scheduling part … -
Why does my database lose recent data ? Django application deployed on Heroku
I have deployed a Django web application on Heroku and it has the data I have added in the development phase, still when I add new data, the website holds the data temporarily for some time ( I don't know how long ), and then the website resets to the state in which it was first deployed. I don't understand why this is happening and would appreciate the help. Here is the website if you want to try it for yourself https://help-er2.herokuapp.com/ As I said if you make changes ( you have to register first ) they will hold and be stored for some unknown time to me and after that time they will disappear. Thanks for your time and effort. -
creation time for django model instance
how to know when an instance of django model has been created inside sqlite? i tried many methods but i couldnt know or get when my db instance was created from datetime import datetime, timedelta time_threshold = datetime.now() - timedelta(hours=4) results = x.objects.filter(created__lt=time_threshold) i even tried this code but i got an error as below: Traceback (most recent call last): File "", line 1, in File "C:\Users\momeir\Anaconda3\envs\myEnv\lib\site-packages\django\db\models\query.py", line 941, in filter return self._filter_or_exclude(False, args, kwargs) File "C:\Users\momeir\Anaconda3\envs\myEnv\lib\site-packages\django\db\models\query.py", line 961, in _filter_or_exclude clone._filter_or_exclude_inplace(negate, args, kwargs) File "C:\Users\momeir\Anaconda3\envs\myEnv\lib\site-packages\django\db\models\query.py", line 968, in _filter_or_exclude_inplace self._query.add_q(Q(*args, **kwargs)) File "C:\Users\momeir\Anaconda3\envs\myEnv\lib\site-packages\django\db\models\sql\query.py", line 1393, in add_q clause, _ = self._add_q(q_object, self.used_aliases) File "C:\Users\momeir\Anaconda3\envs\myEnv\lib\site-packages\django\db\models\sql\query.py", line 1412, in _add_q child_clause, needed_inner = self.build_filter( File "C:\Users\momeir\Anaconda3\envs\myEnv\lib\site-packages\django\db\models\sql\query.py", line 1286, in build_filter lookups, parts, reffed_expression = self.solve_lookup_type(arg) File "C:\Users\momeir\Anaconda3\envs\myEnv\lib\site-packages\django\db\models\sql\query.py", line 1112, in solve_lookup_type _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta()) File "C:\Users\momeir\Anaconda3\envs\myEnv\lib\site-packages\django\db\models\sql\query.py", line 1539, in names_to_path raise FieldError("Cannot resolve keyword '%s' into field. " django.core.exceptions.FieldError: Cannot resolve keyword 'created' into field. Choices are: contact_name, email_name, id, message, subject -
Django: how to pass username to PasswordResetDoneView
PasswordResetView: The user enters his email to reset password. PasswordResetDoneView: The user gets a message "Email sent" I want to let the user what email he entered in the PasswordResetView. How can I pass the email entered (which is the username in my case) to the PasswordResetDoneView html template? path('reset-password/', auth_views.PasswordResetView.as_view(template_name='password_reset/password_reset.html', email_template_name='password_reset/password_reset_email.html', subject_template_name="password_reset/password_reset_asunto.txt"), name='password_reset'), path('reset-password-done', auth_views.PasswordResetDoneView.as_view( template_name='password_reset/password_reset_done.html'), name='password_reset_done'), -
App deployed on Heroku doesn't show data from MySql DB
On development, I set up a clever cloud MySQL database to my Django project with these settings: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'db-name', 'HOST': 'db-name-mysql.services.clever-cloud.com', 'PORT': 3306, 'PASSWORD': 'password', 'USER': 'user' } } It worked normally, so I created some data on this DB for testing. I deployed this app on Heroku, and when I successfully deploy it, I realized that the data shown on Heroku, is not the same as my clever cloud DB. I don't know if Heroku is using another database or why is not using my database.