Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
django one-to-many only show the many from one in a form
I hope the title makes a little bit sence ^^ Ok my problem is, I have two models, like: class Podcast(models.Model): title = models.CharField(max_length=100) description = models.TextField() feeds = models.ForeignKey('Feed', on_delete=models.CASCADE) def __str__(self): return self.title class Feed(models.Model): url = models.URLField(unique=True) def __str__(self): return self.url Now when I go to django admin and create a new podcast, it shows me the feeds from another podcast in the feeds list. What can i do to show only the feeds for that podcast, or no feeds when i create a new podcast? -
How to create GIN index in Django migration
In Django, since version 1.11 we have a class for PostgreSQL GinIndex (https://docs.djangoproject.com/en/1.11/ref/contrib/postgres/indexes/). I'd like to create a migration that constructs such index on a VectorSearchField I added to one of my tables. So far, I've tried to simply add db_index=True to the VectorSearchField, but that fails, because it tries to create a B-Tree index (I think) and the VectorSearchField values are too long. I managed to create the index I want by running a migrations.RunSQL() migration with: CREATE INDEX entryline_sv_index ON entryline USING GIN (sv); However, I guess, since there is a special GinIndex class in Django, maybe there is a way to create such index without executing raw SQL? Here's a model class: import django.contrib.postgres.search as pg_search class EntryLine(models.Model): speaker = models.CharField(max_length=512, db_index=True) text = models.TextField() sv = pg_search.SearchVectorField(null=True) # I want a GIN index on this field. Any idea how to properly create an index for sv field in a migration? Or is executing the CREATE INDEX ... query the best way? -
Create a special button
In Django, I would like to create a button that will send a message (e.g., 'Hello Dear,') to a specific email address. I know we could use a AJAX call for that kind of task. Assume we have two email addresses : from@email.com and to@email.com. The first one will send the message and the second will receive the message. I would like that someone could build a full answer to this question with all files to use (e.g., urls.py, views.py, models.py, template.html). Could anyone have time to do such thing? -
Survey in django. How do I input multiple choice into model?
Im struggling doing a survey with multiple choice selection. I have seen official tutorial, however it was not exactly what I wanted. I am not really sure if my html is correct, but that I can figure out afterwards. What I want is that my survey would be submitted and saved to database(heroku postgresql). I have seen some survey frameworks for django, from what I seen they are not up to date, so not sure if it's useful for django 1.10. Anyways, I would greatly appreciate any kind of help! // Tho, I firstly did html code than i started doing my models, may be this is the problem,but if you could point me out how to do more or less the same survey on django views/forms first, would appreciate it as well ! My models.py from __future__ import unicode_literals from django.db import models from multiselectfield import MultiSelectField # Create your models here. class User_prefs(models.Model): cuisine_choice = ( ('1','Italian'), ('2','American'), ('3', 'Japanese'), ('4','French'), ('5','Mexican'), ('6', 'Chinese'), ('7','Indian'), ('8', 'Middle Eastern') ) lunch_pref = (('1','Coffeehouse'), ('2', 'Cafe'), ('3', 'Restaurant'), ('4','Fast Food'), ('5', 'Takeaway'), ('6', 'Stake House') ) dinner_pref = (('1', 'Restaurant'), ('2', 'Takeaway'), ('3', 'Delivery'), ('4', 'Fast food'), ('5', 'Coffeehouse'), ('6', … -
django custom template filter with variable as argument
I'm using a Django custom template filter as described here to access entries in a 3D array in my template. I pass the 3D array swipeData from views.py to index.html. index.html: function getNearestHalfHourTimeString() { var now = new Date(); var hour = now.getHours(); var minutes = now.getMinutes(); var ampm = "AM"; if (minutes < 15) { minutes = "00"; } else if (minutes < 45){ minutes = "30"; } else { minutes = "00"; ++hour; } return("T" + hour + minutes); } var currentDay = (new Date()).getDay(); var currentTimeRounded = getNearestHalfHourTimeString(); {% block content %} {% load hello_extras %} var atrium = {{swipeData|bldIndex:'ATRIUMCAFE'|dayIndex:currentDay|timeIndex:currentTimeRounded }}; {% endblock %} hello_extras.py: from django import template register = template.Library() @register.filter def bldIndex(List, strIndex): dctBuild = {'ATRIUMCAFE':0, 'BUTLERCOLLEGE':1, 'CAFEVIVIAN':2, 'CENTERFORJEWISHLIFE':3, 'CHANCELLORGREEN':4, 'CHEMISTRYCAFE':5, 'CONCESSIONS_12':6, 'FORBESCOLLEGE':7, 'FRISTCSTORE':8, 'FRISTGALLERY1':9, 'FRISTGALLERY2':10, 'FRISTGALLERY3':11, 'FRISTGALLERY4':12, 'FRISTWITHERSPOONS':13, 'GRADUATECOLLEGE':14, 'LIBRARY_CART':15, 'MATHEYCOLLEGE':16, 'ROCKEFELLERCOLLEGE':17, 'STUDIO34BUTLEREMPORIUM':18, 'WHITMANCOLLEGE':19, 'WILSONCOLLEGE':20, 'WOODROWWILSONCAFE':21, 'FIRESTONELIBRARY':22} i = int(dctBuild.get(strIndex)) return List[i] @register.filter def dayIndex(List, strIndex): return List[int(strIndex)] @register.filter def timeIndex(List, strIndex): dctTime = { "T0000":0, "T0030":1, "T0100":2, "T0130":3, "T0200":4, "T0230":5, "T0300":6, "T0330":7, "T0400":8, "T0430":9, "T0500":10, "T0530":11, "T0600":12, "T0630":13, "T0700":14, "T0730":15, "T0800":16, "T0830":17, "T0900":18, "T0930":19, "T1000":20, "T1030":21, "T1100":22, "T1130":23, "T1200":24, "T1230":25, "T1300":26, "T1330":27, "T1400":28, "T1430":29, "T1500":30, "T1530":31, "T1600":32, "T1630":33, "T1700":34, "T1730":35, "T1800":36, "T1830":37, … -
MySQL is not connecting to RDS AWS
I am developping a web application using Django and AWS Elasticbeanstalk. As database I decided to use MySQL so I followed AWS's tutorial step by step to deploy a Django web appliciation to EBS and to add the instance to my application, but when I try to migrate my models to the database, I get this error: C:\Users\user\project>python manage.py migrate Traceback (most recent call last): File "C:\Python34\lib\site-packages\django\db\backends\base\base.py", line 199, in ensure_connection self.connect() File "C:\Python34\lib\site-packages\django\db\backends\base\base.py", line 171, in connect self.connection = self.get_new_connection(conn_params) File "C:\Python34\lib\site-packages\django\db\backends\mysql\base.py", line 263, in get_new_connection conn = Database.connect(**conn_params) File "C:\Python34\lib\site-packages\MySQLdb\__init__.py", line 81, in Connect return Connection(*args, **kwargs) File "C:\Python34\lib\site-packages\MySQLdb\connections.py", line 204, in __init__ super(Connection, self).__init__(*args, **kwargs2) _mysql_exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'xxxx.xxxx.eu-central-1.rds.amazonaws.com' (10060)") The above exception was the direct cause of the following exception: Traceback (most recent call last): File "manage.py", line 24, in <module> execute_from_command_line(sys.argv) File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line utility.execute() File "C:\Python34\lib\site-packages\django\core\management\__init__.py", line 359, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\Python34\lib\site-packages\django\core\management\base.py", line 294, in run_from_argv self.execute(*args, **cmd_options) File "C:\Python34\lib\site-packages\django\core\management\base.py", line 342, in execute self.check() File "C:\Python34\lib\site-packages\django\core\management\base.py", line 374, in check include_deployment_checks=include_deployment_checks, File "C:\Python34\lib\site-packages\django\core\management\commands\migrate.py", line 61, in _run_checks issues = run_checks(tags=[Tags.database]) File "C:\Python34\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "C:\Python34\lib\site-packages\django\core\checks\database.py", line 10, in … -
Checkboxes in Django Form not updating DataBase
I have a form that is updating text but not updating checkboxes in my database. The checkboxes are a boolean model in the database (postgres) where f is false and t is true. I've looked at a few other tutorials and tried to use multiple choice without much success. I'll apologize ahead of time because I'm self taught in django and this is my first deplorable app. Here is the forms.py module from django import forms from .model import parcels class tableedit(forms.ModelForm): class Meta: model = parcels fields = [ "some_number", "boolean_checkbox_1", "boolean_checkbox_2" ] Here is the the model in model.py from django.db import models from django.contrib.postgres.fields import ArrayField from django.core.urlresolvers import reverse class TableName(models.Model): name = 'table_name' verbose_name = 'table_name' some_number = models.CharField('some_number', max_length=30) boolean_checkbox_1 = models.BooleanField('boolean_checkbox_1 ', max_length =1) boolean_checkbox_2 = models.BooleanField('boolean_checkbox_2', max_length = 1) # Returns the string representation of the model. def __str__(self): # __unicode__ on Python 2 return self.name def get_absolute_url(self): return reverse("table_edit:view", kwargs={"id": self.id}) class Meta: managed = True db_table = 'table' Here is my views.py from django.shortcuts import render, redirect from django.http import HttpResponse from django.http import HttpResponseRedirect from django.core.urlresolvers import reverse from django.views.generic import UpdateView,View from django.contrib import auth from django.views.decorators.csrf import … -
Sending different errors depending on url Django
I am working in Django and I have a situation where I have written a custom validator that lives in the model.py This validator should return a validationError when the input is bad. In the project I am working on, we are using Django Rest Framework for our API and the Django admin panel for our admin panel. They connect to the same DB My problem is that when the request comes from the API I need to return a 'serializers.ValidationError' (which contains a status code of 400), but when the request comes from the admin panel I want to return a 'django.core.exceptions.ValidationError' which works on the admin panel. The exceptions.ValidationError does not display correctly in the API and the serializers.ValidationError causes the admin panel to break. Is there some way I can send the appropriate ValidationError to the appropriate place? Thank you -
How do I get the whole JSON object in Django using DRF3?
When I make a call to my API (curl), I get the following: {"id": 1, "name": "Sword", "persona": [1]} I'm getting the 'id' of the persona, but not the properties within. How do I do this? Models.py: class Persona(models.Model): name = models.CharField(max_length=255) description = models.CharField(max_length=255) icon = models.CharField(max_length=255,default='1') def __str__(self): return self.name class Equipment(models.Model): personas = models.ManyToManyField(Persona) name = models.CharField(max_length=255) def __str__(self): return self.name Serializers.py: class EquipmentSerializer(serializers.ModelSerializer): personas = serializers.PrimaryKeyRelatedField(queryset=Persona.objects.all(), many=True) name = serializers.CharField(max_length=255) class Meta: model = Equipment fields = ('id', 'name', 'persona') -
What order does my Django middleware go in when using GZipMiddleware and UpdateCacheMiddleware middleware
I have just tried to implement both caching middleware (using memcached) and gzip middleware for my Django application. The Django middleware ordering hints say that you should put GZipMiddleware after UpdateCacheMiddleware, which I did initially, but my the phone kept rendering gibberish after a page refresh after I restarted the memcached service (not on my laptop interestingly) which I assumed was because my application was zipping an already zipped response from the cache (or something like that). Putting GZipMiddleware before UpdateCacheMiddleware worked however, so I think I may have misunderstood something. Would someone be able to confirm whether GZipMiddleware should go before or after UpdateCacheMiddleware? And if I have them the wrong way around below, what could be causing the gibberish I was seeing. My working MIDDLEWARE_CLASSES setting is: MIDDLEWARE_CLASSES = ( 'django.middleware.gzip.GZipMiddleware', "mezzanine.core.middleware.UpdateCacheMiddleware", 'htmlmin.middleware.HtmlMinifyMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', "mezzanine.core.request.CurrentRequestMiddleware", "mezzanine.core.middleware.RedirectFallbackMiddleware", "mezzanine.core.middleware.TemplateForDeviceMiddleware", "mezzanine.core.middleware.TemplateForHostMiddleware", "mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware", "mezzanine.core.middleware.SitePermissionMiddleware", "mezzanine.pages.middleware.PageMiddleware", "mezzanine.core.middleware.FetchFromCacheMiddleware", ) -
I am looking for a quick way to retrieve values from a dictionary in templates
I have the following situation: {% if accounts.count > 0 %} {% for account in accounts %} <div>Balance:<b>{{ **my_dict.account.i**d }}</b></div> <div><a href="/edit/{{ account.id }}"><button>Edit</button></a></div> {% endfor %} {% else %} <p>...</p> {% endif %} . Such arrangement is ok my_dict.account But I'll do something like that. I have two dots my_dict.account.id Is there any way to do this? It would be a good idea to create a variable in template but it does not work for me -
How to retrieve a .wav file through POST in django and store it in a data model?
I am learning VXML and Django. I am trying to find out how to cleanly retrieve a recording from some voice-xml (vxml) browser and pass it to the server side where I use django to further handle the passed information. Then I want to store the file somewhere in a .wav file to replay it later. I have the following code snippets: In the VXML file: <record name="recording" /> [here i record the recording] <filled> <submit next="/url/" method="post" namelist="recording"/> </filled> In the urls.py of django, I would have url(r'^url$', view.index, name='index') The views.index definition def index(request): _recording = [..retrieve .wav from request here] _modelObject = ModelObject(recording= _recording) _modelObject.save() #store recording in some database return render(request, 'genericfile.xml', content_type='text/xml') In the model.py I'd guess I would have a class like: from django.db import model class ModelObject(model.Models) recording = [declare type of .wav file here] How would I go about completing the steps in the [..] in a clean manner? -
is there a way to make a list of optional params? python
Let's say I have a function with one / two option but what if I want to add more later on and more more? Is there a way to make it work without much hussle? def json_response_message(status, message, option=(), option1=()): data = { 'status': status, 'message': message, } data.update(option) data.update(option1) return JsonResponse(data) so I can use it like ummmm json_response_message(True, 'Hello', {'option': option}) -
Mezzanine Facebook Integration
I'm trying to integrate Facebook into a Mezzanine blog site. I would like to automatically post blog posts to Facebook from the mezzanine CMS, similar to mezzanine-twitter. I'm attempting to use the mezzanine-facebook package, however there is very little documentation and I'm new to both Django and Mezzanine. However pip can't seem to find the package: "No matching distribution found for mezzanine-facebook" Has anyone used the package or achieved the desired result using another method? python - 2.7 pip - 9.0.1 django - 1.10.7 mezzanine - 4.2.3 Thanks in advance. -
How to find the database a Django record was loaded from?
How do you find the database that a record was loaded from, utilizing Django's multiple database support? I know how to retrieve a record from the non-default database by doing: record = MyModel.objects.using('otherdatabase').get(id=123) But given the record, how do I lookup the using value? I tried: record._default_manager.db but this always returns default, regardless of the value I sent to using(). -
Wagtail deployment on Centos7
I could really use some help here. I am in the process of setting up a test deployment of wagtail on a CentOS7 box and it seems as though the wsgi daemon is not getting access to the necessary python modules. I have checked permissions on all of the directories in the virtual environment and made sure that the owner was apache as well as the group owner was apache (recursively). SELinux is also in permissive mode while I'm trying to figure this out. It's a fresh install of wagtail, no modifications have been made after running the start command from wagtail. My virtual host config file is as follows: <VirtualHost *:80> ServerName <server.name> ServerAdmin <server.admin> Alias /static /var/www/<virtual.env>/<project.name>/static <Directory /var/www/<virtual.env>/<project.name>/static> Require all granted </Directory> <Directory /var/www/<virtual.env>/<project.name>/wsgi.py> <Files wsgi.py> Require all granted </Files> </Directory> WSGIDaemonProcess <project> python-path=/var/www/<virtual.env>/<project.name>/<project.name>:/var/www/<virtual.env/lib/python3.4/site-packages WSGIProcessGroup <project> WSGIScriptAlias / /var/www/<project.env>/<project.name>/<project.name>/wsgi.py ErrorLog /var/log/httpd/<project.name>_error.log CustomLog /var/log/httpd/<project.name>_access.log combined My project_error.log file contains the following: [Thu May 04 18:50:35.596691 2017] [:error] [pid 13101] [remote 10.30.112.49:52] mod_wsgi (pid=13101): Exception occurred processing WSGI script '/var/www/<project.name>_env/<project.name>/<project.name>/wsgi.py'. [Thu May 04 18:50:35.596712 2017] [:error] [pid 13101] [remote 10.30.112.49:52] Traceback (most recent call last): [Thu May 04 18:50:35.596733 2017] [:error] [pid 13101] [remote 10.30.112.49:52] File "/var/www/<project.name>_env/<project.name>/<project.name>/wsgi.py", line 18, … -
Do not allow superuser to login through django allauth login page
I have a problem. When I deploy my website, I will not enable the Django admin site. But when users try to login through Django allauth login page and if email and password entered are from a superuser it will login that user as he is normal user. I don't want that, I want that superuser can only login on the admin page, which I enable in development mode, but in production mode the admin site is disabled. How can I do that? Thank you. Here is how I disable and enable admin site. I have 2 separate settings.py files, in one I set ADMIN_ENABLED = True and in the other one I set it to False. Than in my urls.py I just do this: from django.conf.urls import url, include from django.contrib.auth.decorators import login_required from django.contrib import admin from django.conf import settings from django.conf.urls.static import static from ckeditor_uploader import views from django.views.decorators.cache import never_cache if settings.ADMIN_ENABLED: urlpatterns = [ url(r'^admin/', include(admin.site.urls)), url(r'^', include('blog.urls', namespace='blogs'), name= 'blog'), # User profile url(r'^profile/', include('user_account.urls', namespace='users'), name= 'user'), # url(r'^ckeditor/', include('ckeditor_uploader.urls')), url(r'^ckeditor/upload/', views.upload, name='ckeditor_upload'), #django-allauth url(r'^accounts/', include('allauth.urls')), url(r'^browse/', never_cache(views.browse), name='ckeditor_browse'), url(r'^captcha/', include('captcha.urls')), ] else: urlpatterns = [ # url(r'^admin/', include(admin.site.urls)), url(r'^', include('blog.urls', namespace='blogs'), name= … -
What are the steps in making a web application that uses Django and Oracle?
I am about to make a web application with Django, and want to connect it with an Oracle database. I would like to run my own Apache web server just to show the application to some potential users. What are the steps in the development of such a web application? I am imagining that I should: Create a database and connect my application to it using cx_Oracle Use HTML, CSS, and the Django framework to write my web application Make a web server with Apache to host my website I really do not know how I will achieve these steps, but what I am most interested to know is if I am making sense in how I think I should proceed. Finally, I have been mentioned Bootstrap, Boilerplate, Javascript, and jQuery to aid me in this project. How do these technologies fit with what I am attempting to do? I will thank you for any help you can provide me. -
Not getting the data to be displayed in chart
This chart shows correctly like so: But this does not display the bar: It displays this line as incorrect where default2 is: Unresolved variable default2 I have commented down below for you to see. Been doing these for days and hours and looked for answers here with no luck. Hopefully you can see where I went wrong. Newbie to this so I appreciate all your help, folks! chart.js var endpoint = '/api/chart/data/'; var defaultData = []; var labels = []; var defaultData2 = []; var labels2 = []; $.ajax({ method: "GET", url: endpoint, success: function (data) { labels = data.labels; defaultData = data.default; setChart() }, error: function (error_data) { console.log("error"); console.log(error_data) } }); $.ajax({ method: "GET", url: endpoint, success: function (data) { labels2 = data.labels2; defaultData2 = data.default2; # default2 displays as incorrect??? setChart2() }, error: function (error_data) { console.log("error"); console.log(error_data) } }); function setChart2(){ var ctx = document.getElementById("myChart5"); var myChart5 = new Chart(ctx, { type: 'bar', data: { labels2: labels2, datasets: [{ label: 'Total', data: defaultData2, backgroundColor: [ 'rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(255, 206, 86, 0.2)', 'rgba(75, 192, 192, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(255, 159, 64, 0.2)' ], borderColor: [ 'rgba(255,99,132,1)', 'rgba(54, 162, 235, … -
Django form submit is not working
I am trying to render a django form with custom styles. When i submit the form it is not working. But when i render the form without custom styles it is working. Below code is my html file content. Could anybody help me to solve my problem. {% load staticfiles %} <!DOCTYPE html> <html> <head> <link rel="stylesheet" type="text/css" href='{% static "signup/css/style.css" %}' /> <link href="http://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css"> <title>SignUp</title> </head> <body> <form id="msform" action="" method="post"> <!-- progressbar --> {% csrf_token %} <center> <ul id="progressbar"> <li class="active">Location on Map</li> <li>Personal Details</li> <li>Account Setup</li> </ul> </center> <!-- fieldsets --> <fieldset> <h2 class="fs-title">Location on Map</h2> <h3 class="fs-subtitle">Your address on planet Earth</h3> <div id="googleMap" style="padding: 119.4px;border: 1px solid #ccc;border-radius: 4px;margin-bottom: 10px;width: 100%;box-sizing: border-box;"></div> <script> function initialize() { var myLatLng = {lat: -25.363, lng: 131.044}; var mapProp = { center:new google.maps.LatLng(17.508742,79.120850), zoom:5, mapTypeId:google.maps.MapTypeId.ROADMAP }; var map=new google.maps.Map(document.getElementById("googleMap"), mapProp); google.maps.event.addDomListener(window, 'load', initialize); google.maps.event.trigger(initialize, "resize"); } </script> <script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCpwz7s9u7ZOnrhafotZ_Pas-LLsMaapiQ&callback=initialize"></script> <input type="button" name="next" class="next action-button" value="Next" /> </fieldset> <fieldset> <h2 class="fs-title">Personal Details</h2> <h3 class="fs-subtitle">We will never sell it</h3> {{ form.fname }} {{ form.lname }} {{ form.phone }} {{ form.address }} <input type="button" name="previous" class="previous action-button" value="Previous" /> <input type="button" name="next" class="next action-button" value="Next" /> </fieldset> <fieldset> <h2 … -
Django 1.10 How to display image inside a blog post?
I have a BlogPost model: class BlogPost(models.Model): post_title = models.CharField(max_length=50) post_text = models.TextField(max_length=10000) As well as BlogPostImage: class BlogPostImage(models.Model): blog_post = models.ForeignKey(BlogPost, related_name='images') image = models.ImageField(upload_to='media/images/cafe/blog') @property def image_url(self): if self.image and hasattr(self.image, 'url'): return self.image.url I have my settings.py configured as such (I have also added the appropriate settings to urls.py): MEDIA_ROOT = BASE_DIR MEDIA_URL = '/media/' As it is right now, uploading the image works. I can see the image in the Admin and I can see it in my directories. When I display my BlogPost on a template, I put a safe filter on the post_text attribute so that I can include HTML in my BlogPost. I need to display the image in the post_text, so what do I set src equal to in my <img> tag? I've tried doing {{ post.image.url }} and several other things but I get a "Not Found" in shell and a broken image on the actual page. -
Enviar imagen adjunta con django
Buenas tardes y ante todo gracias. estoy intentando enviar una imagen como adjunta por email, mediante django. envío el correo correctamente pero cuando quiero adjuntar la imagen me da error. la ruta de la imagen esta guardada en una tabla. la imagen esta alojada en proyecto/media/adjuntos/imagen.jpg. si coloco: msg.attach_file('c:/1.jpg') (la ruta a mano) la imagen se envía correctamente. pero si recupero la imagen de la tabla y coloco: msg.attach_file(imagen.archivo) **me dice que no exisite en el directorio ** la imagen esta guardada en el directorio imprimiendo desde la vista(view) me imprime print((imagen.archivo)) adjuntos/1.jpg. espero sus respuestas, gracias -
Django Date unconverted data remains
I am getting this error Unconverted data remains. The date format is FirstDate = 2017-05-14 SecDate = 2017-05-18 The code that I have tried , producing uncoverted data remains error datetime.datetime.strptime(FirstDate, "%Y-%m-%d").date() What I want to do is get the difference between the 2 dates and convert the 2 dates so they can be stored in a Datefield . Thanks for any help. -
Django-rest-framework permissions
I have UserList from rest_framework import permissions class UserList(generics.ListCreateAPIView): queryset = User.objects.all() serializer_class = UserSerializer permission_classes = (permissions.IsAuthenticated,) As you see I need access only to authenticated users, but I always have all permissions. Any idea? -
Django send_mass_email considerations for large lists
I'm already successfully running an integration with the send Sendgrid.com API for an automated report system for a much lower amount of email addresses. Now I need to send an email campaign to around 1 million addresses. The Django project is running on an ec2 instance with Nginx and Gunicorn. I'm planning to use send_mass_email but I'm unsure about how will the Django server behave with a 1mill request in one port. Of course, I've already checked with Sendgrid about their part of the process but I'm wondering which things should I consider on the server side before sending the campaign.