Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
how to make a playlist in django full code
i want to add a playlist to my project. i am trying to load songs from Desktop to the server and to put them in list. here my codes: detail_playlist - <div class="container-fluid songs-container"> <ul class="nav nav-pills navbar-right" style="margin-bottom: 10px;"> <li role="presentation" class="active"><a href="{% url 'music:detail_playlist' playlist.id %}" title="Playlist">Playlist</a></li> <li role="presentation"><a href="{% url 'music:add_song' playlist.id %}" title="Add A New Song">Add A New Song</a></li> </ul> <div class="panel panel-default"> <div class="panel-body"> <h3>Playlist</h3> <head> <style> #playlist{ list-style: none; } #playlist li a{ color:black; text-decoration: none; } #playlist .current-song a{ color: blue; } </style> </head> <body> <audio src="" controls id="audioPlayer"> Sorry, your browser doesn't support html5! </audio> <ul id="playlist"> <li class="current-song"><a href="http://127.0.0.1:8000/media/לשוב_הביתה_JKzWsSd.mp3">לשוב הביתה</a></li> <li><a href="http://127.0.0.1:8000/media/the_chainsmokers_-_paris_BhGY7WK.mp3">Paris</a></li> <li><a href="http://127.0.0.1:8000/media/לים_suxYthz.mp3">לים</a></li> </ul> <script src="https://code.jquery.com/jquery-2.2.0.js"></script> <script> audioPlayer(); function audioPlayer(){ var currentSong = 0; $("#audioPlayer")[0].src = $("#playlist li a")[0]; $("#audioPlayer")[0].play(); $("#playlist li a").click(function(e){ e.preventDefault(); $("#audioPlayer")[0].src = this; $("#audioPlayer")[0].play(); $("#playlist li").removeClass("current-song"); currentSong = $(this).parent().index(); $(this).parent().addClass("current-song"); }); $("#audioPlayer")[0].addEventListener("ended", function(){ currentSong++; if(currentSong == $("#playlist li a").length) currentSong = 0; $("#playlist li").removeClass("current-song"); $("#playlist li:eq("+currentSong+")").addClass("current-song"); $("#audioPlayer")[0].src = $("#playlist li a")[currentSong].href; $("#audioPlayer")[0].play(); }); } </script> </body> </div> </div> </div> i want to append song from the page:"add_song" to the list in the playlist. def add_song(request, playlist_id): form = PlaylistsForm(request.POST or None, request.FILES or None) playlist = … -
How to use a string to call a queryset in Django?
I have 2 models which have foreign keys referencing a third model. Its something like this: class Foo(models.Model): ... class Model1(models.Model): foo = models.ForeignKey(Foo, related_name='m1_related') class Model2(models.Model): foo = models.ForeignKey(Foo, related_name='m2_related') Now, lets say I have an instance of Foo and a string which is either 'm1' or 'm2'. How can I use this string to call the appropriate queryset using the related names? Something like this: my_str = 'm1' foo.my_str+'_related'.objects.all() Obviously, the above code is just wrong in so many ways, but hopefully that makes it clear. I don't want to use if else conditions for this, as the number of models will be a lot, and all their related names will follow the same pattern. Thanks. -
Django migratons are failing when adding a new field
I'm trying to add a new field to my postgreSql database in another server. When adding a new field named 'aceptada' at ReservaSimple in models.py After applying the change I used python3 manage.py makemigrations python3 manage.py migrate However, it says no changes were detected and that I shouldn't re upload the model. Migration error I've tried to drop the database and migrate again with the new model.py file changed with the new attribute, but when I do the migration, no changes are applied to the columns of postgreSql.I've also tried deleting the migrations directory in the app and migrating again and creating the column manually. However, when running the server I always get this error. server error -
Attribute Error in Uploading Excel File to Django
I am having trouble uploading excel file to my django application. It is a very simple application that should allow a user to upload an excel file with 3 columns. The application will read the contents of this file and process it into bunch of calculations here is my forms.py: class InputForm(forms.Form): FileLocation = forms.FileField(label='Import Data',required=True,widget=forms.FileInput(attrs={'accept': ".xlsx"})) settings.py: FILE_UPLOAD_HANDLERS = ["django_excel.ExcelMemoryFileUploadHandler", "django_excel.TemporaryExcelFileUploadHandler"] views.py: import xlrd from django.shortcuts import render_to_response, render from django.conf.urls.static import static from django.contrib import admin from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.template.context_processors import csrf from io import TextIOWrapper from WebApp.forms import * from django.core.mail import send_mail from django.utils.safestring import mark_safe from django.db import connection import os import csv def analyze(request): if request.method == 'POST': form = InputForm(request.POST,request.FILES['FileLocation']) if form.is_valid(): book = xlrd.open_workbook(request.FILES('FileLocation')) for sheet in book.sheets(): number_of_rows = sheet.nrows number_of_columns = sheet.ncols print(number_of_rows) I upload the file in the form and it gives me an error: AttributeError at /forecast/analyze/ 'ExcelInMemoryUploadedFile' object has no attribute 'get' Request Method: POST Request URL: http://127.0.0.1:8000/data/analyze/ Django Version: 1.11 Exception Type: AttributeError Exception Value: Exception Location: C:\Python36\lib\site-packages\django\forms\widgets.py in value_from_datadict, line 367 Python Executable: C:\Python36\python.exe Python Version: 3.6.4 I am also able to upload a .csv file successfully using the following views.py code: def … -
Django Rest Framework Viewset remove permission for detail route
I have a basic Viewset: class UsersViewSet(viewsets.ModelViewSet): permission_classes = (OnlyStaff,) queryset = User.objects.all() serializer_class = UserSerializer It is bind to the /api/users/ endpoint. I want to create a user profile page, so I need only a particular user, so I can retrieve it from /api/users/<id>/, but the problem is that I want /api/users/<id>/ to be allowed to anyone, but /api/users/ to keep its permission OnlyStaff, so no one can have access to the full list of users. Note: Perhaps it's not such a good implementation, since anyone could brute force the data incremeting the id, but I'm willing to change it from <id> to <slug>. How can I delete the permission from detail route? Thanks in advance. -
Django Save Local File on AWS Elastic Bean Stalk
I'm trying to save a file and run a server-side script from my Django instance. I have everything working perfectly on my local test, but when I try it with AWS I'm getting a 500 error. I'm assuming this is because Django isn't being given sudo permissions on the EB instance. How would I correct this? Thank you! -
How to access parameter variables in django GET?
In my urls file, I have urlpattersn = [ url(r'insight/<id>', views.insights, name=['test']) ] In my views file, I have @api_view(['GET']) def insights(request, id): print id I'm getting a 404 error and it doesn't seem to recognize the in the url either? How do i format a get request with params? -
How to limit the number of rows for a specific foreign key in Django admin?
In my Django project, I have Store and Image tables. As each store has 12 images, I use store foreign key to connect 12 images to a certain store in Image table. I would like to limit the possible number of images to a certain store to be 12. In Store table, I used unique=True to avoid duplicates. However, in Image table, it's kind of different with duplicates because I want to limit 12 images for a certain store. Is it possible in Django admin? -
django python code doesn't return the object I expected
I'm following the example from https://docs.djangoproject.com/en/2.1/topics/db/examples/one_to_one/ Can anyone please help explain why at the lines below doesn't return the 2nd restaurant ("Ace Hardware")? Instead, it return the 1st restaurant ("Demon Dogs"). # Set the place back again, using assignment in the reverse direction: >>> p1.restaurant = r >>> p1.restaurant The code and actual output is as below: from django.db import models class Place(models.Model): name = models.CharField(max_length=50) address = models.CharField(max_length=80) def __str__(self): return "%s the place" % self.name class Restaurant(models.Model): place = models.OneToOneField( Place, on_delete=models.CASCADE, primary_key=True, ) serves_hot_dogs = models.BooleanField(default=False) serves_pizza = models.BooleanField(default=False) def __str__(self): return "%s the restaurant" % self.place.name class Waiter(models.Model): restaurant = models.ForeignKey(Restaurant, on_delete=models.CASCADE) name = models.CharField(max_length=50) def __str__(self): return "%s the waiter at %s" % (self.name, self.restaurant) >>> p1 = Place(name='Demon Dogs', address='944 W. Fullerton') >>> p1.save() >>> p2 = Place(name='Ace Hardware', address='1013 N. Ashland') >>> p2.save() >>> r = Restaurant(place=p1, serves_hot_dogs=True, serves_pizza=False) >>> r.save() >>> r.place <Place: Demon Dogs the place> >>> p1.restaurant <Restaurant: Demon Dogs the restaurant> >>> r.place = p2 >>> r.save() >>> r.place <Place: Ace Hardware the place> >>> p2.restaurant <Restaurant: Ace Hardware the restaurant> >>> r <Restaurant: Ace Hardware the restaurant> >>> p1.restaurant <Restaurant: Ace Hardware the restaurant> >>> r.place <Place: Ace … -
Django/Nginx subdomain (urls)
We have a Django project on domain auth.domain.com. Now we created a presentation webpage which is in it's own app called presentation since it must have access to the project DB and models etc. I know how to make it work with multiple domains (like below), but we need auth.domain.com to starts with project.urls and domain.com with presentation.urls. So when you open auth.domain.com you can see projects root url and when you open domain.com we want user to see what they would see if they opened auth.domain.com/presentation/ before. I think it makes sence, static and media files should work on both domains. server { listen 80; server_name auth.domain.com domain.com; ... location / { include proxy_params; proxy_pass http://unix:/home/django/myproject/myproject.sock; } -
Django Signals - "Created" argument becomes false
I am working on an ECommerce website, I use signals to update the total value in the 'Order'. -> post_save_cart_total() - is called whenever a new cart is created -> post_save_order() - is called whenever an order is created or changed in the cart -> The cart values are updated using the update_total(), which is called in the post_save_order(), under the if statement(which checks if an order is created or not) -> post_save_order() is called after post_save_cart_total() completes{this fn is called only once/everytime a new cart is created} -> post_save_order() is called twice after the cart creation(post_save_cart_total()) -- 1st time to fill in the values for the order -- 2nd time as an update and is called everytime the order is changed Issue -> The Issue I am facing here is, --When post_save_order is called for the 1st time, the value of created = True, control goes into the if statement and update total is called to update the values to the order -- The 2nd time when the post_save_order is called, the value of created is changed created=False and the values are not updated to the order -- So whenever I change the items(add/remove) in the order, the cart … -
Frequently disconnects the mssql server and getting errors like core dumped and sometime memory corruption
I'm using python3.5.2, django==1.11, ubuntu16.04, AWS RDS, MSSQL server 17, UNIXODBC==3.2.1, FREETDS (freetds v0.91, TDS version: 4.2) In my django settings: os.environ['TDSVER'] = '8.0' DATABASES = { 'default': { 'ENGINE': 'sql_server.pyodbc', 'HOST': 'host_name', 'PORT': '1433', 'NAME': 'test', 'USER': 'test', 'PASSWORD': 'test', 'AUTOCOMMIT': True, 'OPTIONS': { 'host_is_server': True, }, } } Internal Server Error: /dashboard Traceback (most recent call last): File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/contrib/sessions/backends/base.py", line 202, in _get_session return self._session_cache AttributeError: 'SessionStore' object has no attribute '_session_cache' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection self.connect() File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/db/backends/base/base.py", line 189, in connect self.connection = self.get_new_connection(conn_params) File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/sql_server/pyodbc/base.py", line 309, in get_new_connection timeout=timeout) pyodbc.OperationalError: ('08001', '[08001] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)') The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/core/handlers/base.py", line 187, in _get_response return get_user_model()._meta.pk.to_python(request.session[SESSION_KEY]) File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/contrib/sessions/backends/base.py", line 57, in __getitem__ return self._session[key] File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/contrib/sessions/backends/base.py", line 207, in _get_session self._session_cache = self.load() File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/contrib/sessions/backends/db.py", line 35, in load expire_date__gt=timezone.now() File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/db/backends/base/base.py", line 213, in ensure_connection self.connect() File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/django/db/backends/base/base.py", line 189, in connect self.connection = self.get_new_connection(conn_params) File "/home/qmcpl/projects/eddie/env_newmodel/lib/python3.5/site-packages/sql_server/pyodbc/base.py", line 309, … -
Add/Edit the field of Model A referencing another Model B from the form of model B
I have 2 django models- class File(models.Model): filename = models.FileField(upload_to='files/', max_length=255) user = models.ForeignKey(User, related_name='+', on_delete=models.SET_NULL, null=True) book = models.ForeignKey('Book', on_delete=models.CASCADE, blank=True, null=True) class Book(models.Model): ref = models.CharField(max_length=64, unique=True, blank=True) ordered_by = models.CharField(max_length=64) I have a form for Book. class BookForm(forms.ModelForm): book_file = forms.FileField(label='Select a file to upload', widget=forms.ClearableFileInput(attrs={'multiple': True}), required=False) class Meta: model = Book exclude = ('ordered_by',) Is there a way that I can somehow access and add the 'filename' field of the model File from the form I have created for Book? Using the foreign key criteria somehow? So that I should be entering the 'ref' and uploading a file, that file should be auto linked with model File. I think this should be possible. I have explored inlineformsets but I cannot understand how should I use them. The examples are not very clear with this type of scenerio. The view I have right now is saving fields as below- if request.method == 'POST': book = Book() form = BookForm(request.POST, request.FILES, instance=book) if form.is_valid(): book = form.save() files = request.FILES.getlist('book_file') for f in files: file_model = File(filename=f, user=User.objects.get(username=request.user), book=book) file_model.save() While it's working, it is not very neat. Is there a better way of doing this. So … -
Django ORM get maximum value of a field and corresponding other column values
I have a DataFrame: `exp_no` 'time' 'price' 1 0:00:00 20.0 1 7 days 45.0 1 15 days 100.0 2 0:00:00 20.0 2 7 days 45.0 2 15 days 100.0 The corresponding Django model: class StData(models.Model): exp_no = models.ForeignKey(StIndex, on_delete=models.CASCADE) time = models.DateTimeField() price = models.DecimalField(max_digits=10, decimal_places=2) I want to make a smaller table which would have exp_no, max_time and corresponding price such that: `exp_no` 'time' 'price' 1 15 days 100.0 2 15 days 100.0 In pandas, I'd do df.groupby('exp_no')['time', 'price'].max().reset_index() to get the desired table. In Django ORM annotation to get the same result(or Queryset) if I do: qs.values('exp_no').annotate(max_time=Max('time')).order_by() it gives me exp_no and time, but I want to get the corresponding price as well. I have looked through this answer in SO: Django orm get latest for each group But not sure how I get the price. Using Django 2.0 with sqlite3. I appreciate any help. -
Not able to save date from datepicker into my database
I am new in Django. Basically i have a form in which i have a date_of_birth field and i am take imput into it through a datepicker widget. But i am not able to store it into my database(SQLite). Here's my model.py-: class users(models.Model): id = models.IntegerField(primary_key=True) name = models.CharField(max_length=50) email = models.CharField(max_length=50) dob = models.DateField(max_length=30) phone = models.IntegerField() def __str__(self): return self.name here's forms.py-: class DateInput(forms.DateInput): input_type = 'date' class user_form(forms.ModelForm): name = forms.CharField(widget=forms.TextInput(),required=True,max_length=30) email = forms.CharField(widget=forms.EmailInput(), required=True, max_length=50) phone = forms.IntegerField(widget=forms.NumberInput) dob = forms.DateField(widget=DateInput(attrs={'class':'datepicker'})) class Meta(): model = users fields = ['name', 'email', 'phone', 'dob'] here's View.py-: def userdata(request): if request.method == 'POST': form = user_form(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/user-form/') else: form = user_form() return render(request, 'user_form.html',{'form':form}) -
remaining connection slots are reserved for non-replication superuser connections
I currently have a django application, and have a postgreSQL database. I have researched this error, and have found other answers on Stackoverflow, but none seem to answer my exact question. I am getting this error when a request is made to a server. Note that I am currently running my application locally. A lot of my views contain requests to the database: django.db.utils.OperationalError: FATAL: remaining connection slots are reserved for non-replication superuser connections Here are the configurations for the database that are in my settings.py file: Any help would be greatly appreciated! DATABASES = { 'default': { 'ENGINE': 'django_postgrespool', 'NAME': 'database', 'USER': 'user', 'PASSWORD': 'password', 'HOST': 'localhost', 'PORT': '5432', 'CONN_MAX_AGE': 0, } } -
Django upgrade filter/prefetch_related behaviour change?
I'm in the process of upgrading from Django 1.8.19 to 1.11.15 and I've found a piece of code which is breaking. In particular this query is doing something different to what it did before. project_groups = brand.project_groups.prefetch_related( 'project', 'project__score', 'project__themes').filter( project=projects ).distinct() Previously (in Django 1.8), according to the output of "project_groups.query" it produced SQL including: ... projectgroup.project_id IN [projects query] Now it produces SQL reading: ... projectgroup.project_id = [projects query] This breaks as the [projects query] returns more than one row. So I get a: ProgrammingError: more than one row returned by a subquery used as an expression The only changes I've made to the code for this upgrade are to models and migrations to use ArrayField and HStoreField from django.contrib.postgres.fields instead of the django_hstore equivalents. My guess is that the original code was wrong, but worked due to a bug in Django (filter/prefetch_related) which has now been fixed. Is that likely to be correct? If so what's the simplest way to rewrite this query? If this is in fact a new bug in Django I don't want to write code which relies on it! -
Django 2.1 NoReverseMatch error Using post method in Class Based Views
Url : re_path(r'^detail/(?P<slug>\w+)/$',ProblemDetail.as_view(),name='problem_detail'), View : class ProblemDetail(View): template_name='problem/problem_detail.html' form_class=AnswerForm def get(self,request,slug): context={'problem':Problem.objects.get(slug=slug),'form':self.form_class()} return render(request,self.template_name,context) def post(self,request,slug): bound_form=self.form_class(request.POST) obj=Problem.objects.get(slug=slug) real_answer=obj.answer if bound_form.is_valid(): if cleaned_data['answer'] == real_answer: return render(request,'problem/Answerstatus.html',{'message':'Good Job !'}) else: return render(request,'problem/Answerstatus.html',{'message':'Wrong ! Try Again !'}) I get The Following Error : Reverse for 'problem_detail' with no arguments not found. 1 pattern(s) tried: ['detail/(?P\w+)/$'] -
Django project on DigitalOcean server
I've posted my first Django project (internet shop) on the server of DigitalOcean. Everything works well except one thing: when I order items on the page of products I need click button "Buy" and after that I have to see page "Checkout" where I can fill in all fields for order. But... After clicking on the button "Buy" I see page with the only message "Server Error 500". Please, help me fix this problem! -
Retain Cache with Django
I am hoping to use Django's cache to keep track of a list of companies returned by an external API call. However, on weekends the server I am calling from returns a blank list. I am definitely a noob at this, but is there a way to use the last cache if the API call returns a blank list? Thanks. -
django type object 'PoliceDefenceJobs' has no attribute 'objects'
Here is my models.py class PoliceDefenceJobs(models.Model): police_defence_id = models.AutoField(primary_key=True) start_date = models.CharField(max_length=60) last_date = models.CharField(max_length=60) post_name = models.CharField(max_length=255) education = models.CharField(max_length=255) more_info = models.TextField() requirement_board = models.CharField(max_length=255) type = models.IntegerField() job_id = models.IntegerField(default=None,blank=True,null=True) join_id = models.IntegerField(default=None,blank=True,null=True) def __str__(self): return "Police Defence Jobs" here is my views.py class PoliceDefenceJobs: def police_defence_jobs(request): PoliceDefenceJobs.objects.all().delete() return JsonResponse({"code":200}) Here i am getting type object 'PoliceDefenceJobs' has no attribute 'objects' error.. -
FOREIGN KEY constraint failed in Django TabularInline
I have 2 models: Responsavel and Filho. Responsavel can have a lot of Filhos, so in my admin.py file i have the following: class FilhoInline(admin.TabularInline): model = Filho @admin.register(Responsavel) class ResponsavelAdmin(admin.ModelAdmin): inlines = [ FilhoInline ] def save_model(self, request, obj, form, change): obj.user.is_pai = True obj.user.save() super().save_model(request, obj, form, change) With this i can insert Responsavel and Filho in same screen, much more usable. So, in my models.py i have: class Responsavel(models.Model): user = models.OneToOneField(TogetherUser, verbose_name="Usuário", primary_key=True, on_delete=models.CASCADE) cpf = models.CharField(max_length=11, unique=True) telefone1 = models.CharField(max_length=50, blank=True, null=True) telefone2 = models.CharField(max_length=50, blank=True, null=True) telefone3 = models.CharField(max_length=50, blank=True, null=True) def __str__(self): return self.user.username class Meta: verbose_name_plural = "Responsáveis" verbose_name = "Responsável" class Filho(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) nome = models.CharField(max_length=100) data_nascimento = models.DateField(verbose_name="Data de Nascimento") genero = models.CharField(max_length=1, choices=Genero.choices(), verbose_name="Gênero") responsavel = models.ForeignKey(Responsavel, on_delete=models.PROTECT, verbose_name="Responsável") def __str__(self): return self.nome class Meta: verbose_name_plural = "Filhos" When i try to save the Responsavel and your "Filhos" inside Admin Django i got the following error: IntegrityError at /admin/core/responsavel/add/ FOREIGN KEY constraint failed But if i add Responsavel without any "Filhos" everything works. -
Django Exception: botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the CreateMultipartUpload operation: Access Denied
I want to use django-storages to store my model files in Amazon S3 but I get Access Denied error. I have granted the user almost all S3 permission PutObject, ListBucketMultipartUploads, ListMultipartUploadParts, AbortMultipartUpload permissions, etc. on all resources but this didn't fix it. settings.py ... DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' AWS_S3_REGION_NAME = 'eu-west-1' AWS_S3_CUSTOM_DOMAIN = 'www.xyz.com' AWS_DEFAULT_ACL = None AWS_STORAGE_BUCKET_NAME = 'www.xyz.com' ... Using the Django shell, I tried to use the storage system as shown below. Python 3.6.6 (default, Sep 12 2018, 18:26:19) [GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> import os >>> AWS_ACCESS_KEY_ID = os.environ.get( 'AWS_ACCESS_KEY_ID', 'anything' ) >>> AWS_SECRET_ACCESS_KEY = os.environ.get( 'AWS_SECRET_ACCESS_KEY', 'anything' ) >>> AWS_DEFAULT_ACL = 'public-read' >>> from django.core.files.storage import default_storage >>> file = default_storage.open('test', 'w') ... >>> file.write('storage contents') 2018-09-27 16:41:42,596 botocore.hooks [DEBUG] Event before-parameter-build.s3.CreateMultipartUpload: calling handler <function validate_ascii_metadata at 0x7fdb5e848d08> 2018-09-27 16:41:42,596 botocore.hooks [DEBUG] Event before-parameter-build.s3.CreateMultipartUpload: calling handler <function sse_md5 at 0x7fdb5e848158> 2018-09-27 16:41:42,597 botocore.hooks [DEBUG] Event before-parameter-build.s3.CreateMultipartUpload: calling handler <function validate_bucket_name at 0x7fdb5e8480d0> 2018-09-27 16:41:42,597 botocore.hooks [DEBUG] Event before-parameter-build.s3.CreateMultipartUpload: calling handler <bound method S3RegionRedirector.redirect_from_cache of <botocore.utils.S3RegionRedirector object at 0x7fdb5c5d1128>> 2018-09-27 16:41:42,597 botocore.hooks [DEBUG] Event before-parameter-build.s3.CreateMultipartUpload: calling handler <function generate_idempotent_uuid at 0x7fdb5e846c80> 2018-09-27 … -
Not getting smtp repsonse?
in my project I am trying to send a password reset link to an email but I am not getting any smtp response. Any thoughts as to why this is happening? urlpatterns: url(r'^reset-password/$', PasswordResetView.as_view(template_name='accounts/reset_password.html', success_url=reverse_lazy('accounts:password_reset_done')), name='reset_password'), url(r'^reset-password/done/$', PasswordResetDoneView.as_view( template_name='accounts/reset_password_email.html'), name='password_reset_done'), url(r'^reset-password/confirm(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,23})/$', PasswordResetConfirmView.as_view(), name='password_reset_confirm'), url(r'^reset-password/complete/$', PasswordResetCompleteView.as_view(), name='password_reset_complete'), cmd: [27/Sep/2018 17:48:43] "GET /account/reset-password/ HTTP/1.1" 200 2107 account/reset-password/ [27/Sep/2018 17:48:48] "POST /account/reset-password/ HTTP/1.1" 302 0 account/reset-password/done/ cmd/smtp: -m smtpd -n -c DebuggingServer localhost:1025 html: <form method='post'> {% csrf_token %} {{ form.as_p }} <button type="submit">Submit</button> </form><br /> </div> If there's anything else I need to include please let me know as I am a little unsure. TIA -
Django rest framework user specific
I'm confused about one part of how DRF works, I'm using django-rest-auth to register users. I would after that like them to each get a field in the models below, so that when they have picked fruit they can update their field and no one elses however I'm not really sure how I am suppost to link the django-rest-auth table with the other two and how I check which user it is that is updating their table class fruits(models.Model): apples = models.IntegerField() bananas = models.IntegerField() oranges = models.IntegerField() class berries(models.Model): strawberries = models.IntegerField() blackberries = models.IntegerField()