Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to connect fields in the Serializer (DjangoRestFramework)?
I have a read access to SQL-legacy DB. Suppose in the DB I have two tables: Treatment and TreatmentType. In the Treatment table, I have patientID (int), date (text), treatmentType (int). In the TreatmentType table, I have code(int) and meaning (Text). The Treatment.treatmentType is the code for finding the meaning in the TreatmentType table. During the first migration, I use a built-in method:inspectdb from django, and I get something like this: class TreatmentType(models.Model): index = models.TextField(primary_key=True) code = models.IntegerField(db_column='Code', blank=True, null=True) # Field name made lowercase. meaning = models.TextField(db_column='Meaning', blank=True, null=True) # Field name made lowercase. class Meta: managed = False db_table = 'TreatmentType' class Treatment(models.Model): index = models.TextField(primary_key=True) patient = models.IntegerField(db_column='PATIENT', blank=True, null=True) # Field name made lowercase. date = models.TextField(db_column='DATE', blank=True, null=True) # Field name made lowercase. This field type is a guess. treatmenttype = models.IntegerField(db_column='TREATTYPE', blank=True, null=True) # Field name made lowercase. class Meta: managed = False db_table = 'Treatment' From the model, I want to have a REST API for getting the list of treatment with an extra column TreatmentMeaning. I use DjangoRestFramework to create the serializers for me: class TreatmentModelSerializer(serializers.ModelSerializer): meaning = serializers.SerializerMethodField('get_meaning') def get_meaning(self, instance): meaning = TreatmentType.objects.get(code=instance.treatmenttype).meaning return meaning class Meta: model = โฆ -
Angular with angular with restful api VS MVC (django, laravel, node.js etc.)
Good morning everybody, just a simple question. I know it is trivial but I found contradicting information on the web. I am moving from developing desktop applications to web apps: (single page and not). I can see that AngularJS with restful API is gaining a lot of attention and popularity. Is this the best approach to build web app or just a trend? What are the advantages of this solution compared to more traditional MVC framework like Django, Laravel, etc? Have you used both this approaches? Can you share your thoughts with me? Thank you. -
cannot convert dictionary update sequence element #0 to a sequence 5747
T106374 txnid cannot convert dictionary update sequence element #0 to a sequence 5747 T106379 txnid this is on my terminal in after 74 id 77 is their but it shows 79 and on downloading the sheet 77 id is their. but on view the report it miss one id 77 why is it so? -
Django-Ldap-Authentication
I am trying to authenticate the user with the LDAP server in django. I have configured my settings.py as follows : AUTH_LDAP_SERVER_URI = "ldap.forumsys.com" AUTH_LDAP_BIND_DN = "cn=read-only-admin,dc=example,dc=com" AUTH_LDAP_BIND_PASSWORD = "password" AUTH_LDAP_USER_SEARCH = LDAPSearch("dc=example,dc=com", ldap.SCOPE_SUBTREE, "(uid=%(user)s)") AUTH_LDAP_START_TLS = True AUTHENTICATION_BACKENDS = ( 'django_auth_ldap.backend.LDAPBackend', 'django.contrib.auth.backends.ModelBackend', ) In my views i have tried to authenticate it with the LDAPBACKEND from django.http import HttpResponse from django_auth_ldap.backend import LDAPBackend from django.contrib.auth.models import User from django.conf import settings def login_user(request): state = "" username = settings.AUTH_LDAP_BIND_DN password = settings.AUTH_LDAP_BIND_PASSWORD auth = LDAPBackend() try: User = auth.authenticate(username=username,password=password) if User is not None: state = "Valid" else: state = "Invalid" except LDAPError as e: state = "Error" return HttpResponse(state) But i am getting an error as LDAPError while authenticating cn=read-only-admin,dc=example,dc=com: LDAPError(0,'Error') And i do have another doubt . Is the username and password is same as the bind_username and bind_password -
Django query set latest object having a particular foreign key
I have a profile model class Profile(models.model): user=models.Foreignkey(user,null=True,blank=True) and class Moods(models.model): email=models.CharField(null=True,blank=True) mood=models.CharField(null=True,blank=True) for a single email there may be many mood like.. test@test.com happy test@test.com sad I want to get a queryset such that the email belongs to a user who has a foreign key in Profile model and the mood is the latest mood that is created for that user -
Scaling django with mod_wsgi to handle 100K requests
I am about to deploy a django application that will be receiving over 100k requests per second. I am using Nginx as my primary webserver as a reverse proxy to Apache mod_wsgi. I would like to know what would be the best combination of WSGIDaemonProcess processes and threads to handle this kind of load. I have already implemented static content caching on nginx as well as using django caching on my views that don't change often. I am a noob at deploying applications of this magnitude and I apoligise if this is too basic. -
Migration in Postgresql and Django 1.8
In my project I am using django 1.8 and for a fresh project if I run python manage.py runserver it shows the following message: You have unapplied migrations; your app may not work properly until they are applied. Run 'python manage.py migrate' to apply them. Then if i run the command python manage.py migrate it works fine for sqlite. But if i connect with postgresql in my local_settings.py and run the above migration command then it gives the following error: django.db.utils.ProgrammingError: relation "django_content_type" does not exist -
Error handling messages for restfull API serving SPA?
We are facing problems working with django rest framework when it comes to error handling. auto-generated errors are json objects that looks like {"age": "this field must be an integer"} Clients need something more user friendly like : age field must be an integer. Any solution to handle this ? -
Django: add ManyToMany between two apps I cannot modify
I have two apps: trains provides the Train model, and railroad the Rail model. Since I totally love trains, I want to ensure that Train can only drive over the compatible Rail, therefore I implement a TrainRailCompatibility. However, I cannot modify neither Train nor Rail model to add a field ManyToMany(through=TrainRailCompatibility) (I am not a maintainer of those apps). I would still like to be able to do in my project something like my_train.compatible_rails.all() or filter(foo__trains__compatible_rails__in=[...]). Is there a way / what would be the best way to achieve it? -
How to share a gif image from website to whatsapp using jQuery so that image should be visible on whatsapp not a link
Problem: In whatsapp it show only link and text not image. I want to share gif image show that when I share on whatsapp the gif image will be visual on the whatsapp app, not by clicking the link I am sending for image. Html <a class="sharebtn bwa fa fa-whatsapp " data-text="Your message goes here.." data-sitename="www.wisheveryone.in" data-link="http://lowcost-env.qqggewfjnm.us-west-2.elasticbeanstalk.com/static/polls/img/birthday.gif"> | Share</a> jQuery $(document).ready(function() { // this jquery is completely for whatsapp sharing button var isMobile = { Android: function() { return navigator.userAgent.match(/Android/i); }, BlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i); }, iOS: function() { return navigator.userAgent.match(/iPhone|iPad|iPod/i); }, Opera: function() { return navigator.userAgent.match(/Opera Mini/i); }, Windows: function() { return navigator.userAgent.match(/IEMobile/i); }, any: function() { return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()); } }; $(document).on("click", '.bwa', function() { if( isMobile.any() ) { var text = $(this).attr("data-text"); var url = $(this).attr("data-link"); var message = encodeURIComponent(text) + " - " + encodeURIComponent(url); var whatsapp_url = "whatsapp://send?text=" + message; window.location.href = whatsapp_url; } else { alert("Please share this article in mobile device"); } }); }); -
Unknown field(s) (username, password2, phone, password1, email) specified for Bookmark
์คํธ์๋๋ฐใ ใ ํ์ด์ฌ ์ฅ๊ณ ๋ก ์น ๊ฐ๋ฐ์ค์ ๋๋ค. ๋ก๊ทธ์ธ ์ email๊ณผ ์ ํ๋ฒํธ๋ฅผ ๋ฐ๊ณ ์ถ์ด์ class UserCreateForm(UserCreationForm): email = forms.EmailField(required=True) phone = forms.CharField(max_length=None) class Meta: model = User fields = ('username', 'password1', 'password2', 'email', 'phone') def save(self, commit=True): user = super(UserCreateForm, self).save(commit=False) user.email = self.cleaned_data["email"] user.phone = self.cleaned_data["phone"] if commit: user.save() return user class UserCreateView(CreateView): template_name = 'registration/register.html' form_class = UserCreateForm success_url = reverse_lazy('register_done') ์ด๋ ๊ฒ ์ ๋ ฅํ์์ต๋๋ค. ๊ทธ๋ฐ๋ฐ ์ํ๊น๊ฒ๋ ์ ์๋ ์ ๋์๊ฐ๋ bookmark์ถ๊ฐ์ blog์ถ๊ฐ๊ฐ ๋ง์ฝ์ ๋๋ค. ๋ฌผ๋ก ํธ์ง๋ ๋ง์ฐฌ๊ฐ์ง์ ๋๋ค. admin์์๋ ๋ฌธ์ ๊ฐ ์๋๋ฐ ์ฌ์ดํธ์์ ์ถ๊ฐํ๋ ค๊ณ ํ๋ฉด ์๋ฌ๊ฐ ๋จ๋ค์ enter image description here ๋ถ๋งํฌ๋ฅผ ์ถ๊ฐํ๋ ๋ทฐ๋ ์ด๋ ๊ฒ ์์ฑํ์์ต๋๋ค. class BookmarkCreateView(LoginRequiredMixin, CreateView): model = Bookmark fields = ['title', 'url'] success_url = reverse_lazy('bookmark:index') def form_valid(self, form): form.instance.owner = self.request.user return super(BookmarkCreateView, self).form_valid(form) ์ด๋๊ฐ ๋ฌธ์ ์ธ์ง ์ ๋ชฐ๋ผ์ ์ผ๋จ ์ง๋ฌธ์ ์ฌ๋ ค๋ด ๋๋คใ -
Acessing Meta ordering from relational model in Django
I am trying to access 'Meta' ordering from ForeignKey relational model and couldn't make it work. following are the models and I need to get ordering of submodel to function of parent model. I can access ordering for Product or Product image in shell but cannot do it with relational submodel. Please advise. Product(models.Model): #parent model .... def primary_image(self): images = self.images.all() ordering = self.images.model._meta.ordering #Just need to get order of submodel Meta here. ProductImages(models.Model): #submodel and images with related name "images". product = models.ForeignKey( 'catalogue.Product', related_name='images', verbose_name=_("Product")) original = models.ImageField( _("Original"), upload_to=settings.MARKET_IMAGE_FOLDER, max_length=255) caption = models.CharField(_("Caption"), max_length=200, blank=True) #: Use display_order to determine which is the "primary" image display_order = models.PositiveIntegerField( _("Display order"), default=0, help_text=_("An image with a display order of zero will be the primary" " image for a product")) class Meta: ordering = ('display_order') -
Placing text and image on the same row in Django
I am building a personal website using Django and I have one app in it - home. On my home page I want to place an image and text on the same row (side by side). I have tried several ways to do this using Bootstrap but none of them seem to work. Below is my code and the text appears right below the image instead of being NEXT to the image. home's template.html <!DOCTYPE html> <html lang="en"> <head> <title>My Website</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Boostrap --> {% load staticfiles %} <link rel="stylesheet" href="{% static 'home/css/bootstrap.css' %}"> <link rel="stylesheet" href="{% static 'home/css/basic.css' %}"> <!-- Font-Awesome (Icons) --> <script src="https://use.fontawesome.com/8e86dbd2db.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> </head> <body> <nav class="navbar navbar-inverse"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="#">Pranav Gupta</a> </div> <ul class="nav navbar-nav"> {% url 'home:index' as index %} {% url 'home:portfolio' as portfolio %} {% url 'home:blog' as blog %} {% url 'home:contact' as contact %} <li {% if request.path == index %} class="active" {% endif %} ><a href="{% url 'home:index' %}">Home</a></li> <li {% if request.path == portfolio %} class="active" {% endif %} ><a href="{% url 'home:portfolio' %}">Portfolio</a></li> <li {% if request.path == blog %} class="active" {% endif %} โฆ -
ImportError: cannot import name regist error
I am making registration form in web.But,I got ImportError: cannot import name regist error and further ImportError: cannot import name regist. I made regist.html and I thought I could assign the html. I wrote in urls.py of accounts(child app) from django.conf.urls import url from django.contrib.auth.views import login, logout, regist urlpatterns = [ url(r'^login/$', login, {'template_name': 'registration/accounts/login.html'}, name='login'), url(r'^logout/$', logout, name='logout'), url(r'^regist/$', regist, {'template_name': 'registration/accounts/regist.html'}, name='regist'), url(r'^regist_save/$', views.regist_save, name='regist_save'), ] in regist.html, {% extends "main/base.html" %} {% block content %} <form class="my-form" action="{% url 'main:regist_save' %}" method="POST"> <div class="form-group"> <label for="id_username">username</label> {{ form.username }} {{ form.username.errors }} <p class="help-block">{{ form.username.help_text }}</p> </div> <div class="form-group"> <label class="control-label" for="id_password1">pass</label> {{ form.password1 }} {{ form.password1.errors }} </div> <div class="form-group"> <label class ="control-label" for="id_password2">pass๏ผagain๏ผ</label> {{ form.password2 }} {{ form.password2.errors }} <p class="help-block">{{ form.password2.help_text }}</p> </div> <div class="form-group"> <div> <input type="submit" class="btn btn-default" value="regist"> </div> </div> {% csrf_token %} </form> {% endblock %} login & logout can be worked,so I cannot understand how to fix it. -
I used the django EmailMessage to send an email, but in some mailbox, the attachment's filename show as messy code
How to fix this issue, maybe can set the encode of attachment filename? The attachment name is Chinese -
Django pagination indicates download
I would like to know how to use pagination on django. I have tried example which is in Django document and several example on stackoverflow. However I could not find how can I make it work. This is code: views.py def test_result(request, report_id, repetition_id, test_id) : context = {} query = """ ##this is query### """ % (report_id, repetition_id, test_id) report_info = list(query_to_dicts(query)) context['report_info'] = report_info[0] query = """ ## this is another query## """ % (report_id, repetition_id, test_id) result_summary = list(query_to_dicts(query)) context['result_summary'] = result_summary[0] query = """ ### this is the other query### """ % (test_id, test_id) test_result = query_to_dicts(query) context['test_result'] = test_result query = """ ###too much query """ % (report_id) left = list(query_to_dicts(query)) obj = query_to_dicts(query) left = list() exe_num = 0 context['left'] = left ##pagination## step_list=Step.objects.all() paginator=Paginator(step_list,5) page=request.GET.get('page') try: steps=paginator.page(page) except PageNotAnInteger: steps=paginator.page(1) except EmptyPage: steps=paginator.page(paginator.num_pages) models.py class Step(models.Model): test = models.ForeignKey(Test, on_delete=models.CASCADE) test_file = models.TextField() line_no = models.IntegerField() execution_time = models.DateTimeField() module = models.TextField() callstack_level = models.IntegerField() result = models.BooleanField() and template.html... <span class="step-links"> {% if steps.has_previous %} <a href="?page={{ steps.previous_page_number }}">previous</a> {% endif %} <span class="current"> Page {{ steps.number }} of {{ steps.paginator.num_pages }}. </span> {% if steps.has_next %} <a href="?page={{ steps.next_page_number }}">next</a> {% โฆ -
Elasticsearch vs Elasticsearch with haystack
I am going to use elasticsearch to implement search in my django project but am not sure whether i should use it directly or with haystack wrapper ,I know that using it directly would give me a performance boost bur other than than what are various factors that i should keep in mind while choosing like for example right now i just need text based search but as the project grows my requirements may change. In terms of performance how slow is haystack with elasticsearch as compared to elasticsearch. Also it would be great help if you could tell some tutorials on how to use elasticsearch directly with django. -
How do I get the current "username" in django 1.10?
I'm trying to fill a field in my model with the current username in django 1.10. This is the code that I'm using. And I'm getting the next error: TypeError: get_username() missing 1 required positional argument: 'self' Am I doing this wrong? By the way, I dont wanna use a view, I am trying to do this directly from the admin site. -
ClientError: The AWS Access Key Id you provided does not exist in our records
I am using a Django website running on an ubuntu EC2 instance with S3 for hosting my static and media. When I try to upload an image file to a model I receive the following. "An error occurred (InvalidAccessKeyId) when calling the PutObject operation: The AWS Access Key Id you provided does not exist in our records." I have an iam user with AmazonS3FullAccess and I copy and pasted the correct Access key into my settings.py file. I am able to run collectstatic and access the buckets through the terminal, and I even have my static served correctly on my website, but no user can upload images or files. I'v run and rerun aws configure, but still no luck. Here is the relevant code from my utils.py and settings.py: utils.py from storages.backends.s3boto3 import S3Boto3Storage class StaticStorage(S3Boto3Storage): location = 'static' class MediaStorage(S3Boto3Storage): location = 'media' AWS_ACCESS_KEY_ID = 'access_key' AWS_SECRET_ACCESS_KEY = 'secret_key' S3_REGION_NAME ='aws_region' settings.py DEFAULT_FILE_STORAGE = 'my-project.utils.MediaStorage' AWS_STORAGE_BUCKET_NAME = 'my-project-bucket' STATICFILES_STORAGE = 'my-project.utils.StaticStorage' AWS_S3_CUSTOM_DOMAIN = '//%s.s3-us-gov-west-1.amazonaws.com' % AWS_STORAGE_BUCKET_NAME MEDIA_URL = AWS_S3_CUSTOM_DOMAIN + 'media/' STATIC_URL = AWS_S3_CUSTOM_DOMAIN + 'static/' MEDIA_ROOT = MEDIA_URL ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/' my /.aws/config and credentials file also have the same copy and pasted Id and Keys. โฆ -
How to assign a ForeignKey field when a new instance is created
I'm building a comment system and trying to implement voting. So on the line comment = Comment.objects.create(comment_text=ajax_comment, author=str(request.user), destination=id) where I create a new Comment object, I want to add an upvotes field. So upvotes=0 when the object is created. How do I do this? models.py class Comment(models.Model): user = models.ForeignKey(User, default=1) destination = models.CharField(default='1', max_length=12, blank=True) author = models.CharField(max_length=120, blank=True) comment_id = models.IntegerField(default=1) parent_id = models.IntegerField(default=0) comment_text = models.TextField(max_length=350, blank=True) timestamp = models.DateTimeField(default=timezone.now, blank=True) def __str__(self): return self.comment_text class CommentScore(models.Model): user = models.ForeignKey(User, default=1) comment = models.ForeignKey(Comment, related_name='score') upvotes = models.IntegerField(default=0) downvotes = models.IntegerField(default=0) def __str__(self): return str(self.comment) views.py comment_list = Comment.objects.filter(destination=id) score = CommentScore.objects.all() if request.is_ajax(): if comment.is_valid(): comment = Comment.objects.create(comment_text=ajax_comment, author=str(request.user), destination=id) print(comment) comment.save() username = str(request.user) return JsonResponse({'text': ajax_comment, 'text_length': comment_length, 'username': username}) else: print(comment.errors) context = { 'score': score, 'comment_list': comment_list, } return render(request, 'article.html', context) -
How to call serializer's create() method from one serializer
I have two serializers, "UserSerializer" and "CustomerSerializer" as bellow class UserSerializer(serializers.ModelSerializer): def create(self, validated_data): return User.objects.create(**validated_data) class Meta: model = User fields = '__all__' class CustomerSerializer(serializers.ModelSerializer): def create(self, validated_data): return Customer.objects.create(**validated_data) class Meta: model = Customer fields = '__all__' When I hit user api with POST request, it calls UserSerializer's create method which saves user object. Now while saving user I want to save customer object as well, using user api. So for from UserSerializer's create method I want to call CustomerSerializer's create() method in order to save customer object as well. How do I do that ? -
crontab with django - fail with email
I'm using django and trying to set up a crontab that executes daily. I saw elsewhere that you can set an email address with crontab, such that if crontab fails, I would get an email to my email address stating that it had failed. I see that you can do this for crontab, but I'm not sure about whether you can do it in Django using crontab. This is what the crontab portion of my settings.py looks like: CELERYBEAT_SCHEDULE = { 'daily-mailer': { 'task': 'tasks.views.mail_automated', 'schedule': crontab(day='*'), 'args': (), } { Any help would be appreciated! -
Django Error Message While Using PyCharm: "'function' object has no attribute 'using'"
While working on coding up a REST API using Django and Django REST Framework I all of a sudden got the following error: Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x1032bc1e0> Traceback (most recent call last): File "/Users/alexarias/PycharmProjects/ContratRestAPI/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "/Users/alexarias/PycharmProjects/ContratRestAPI/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 113, in inner_run autoreload.raise_last_exception() File "/Users/alexarias/PycharmProjects/ContratRestAPI/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception six.reraise(*_exception) File "/Users/alexarias/PycharmProjects/ContratRestAPI/venv/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise raise value.with_traceback(tb) File "/Users/alexarias/PycharmProjects/ContratRestAPI/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "/Users/alexarias/PycharmProjects/ContratRestAPI/venv/lib/python3.6/site-packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/Users/alexarias/PycharmProjects/ContratRestAPI/venv/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models(all_models) File "/Users/alexarias/PycharmProjects/ContratRestAPI/venv/lib/python3.6/site-packages/django/apps/config.py", line 199, in import_models self.models_module = import_module(models_module_name) File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 978, in _gcd_import File "<frozen importlib._bootstrap>", line 961, in _find_and_load File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 655, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed File "/Users/alexarias/PycharmProjects/ContratRestAPI/employees/models.py", line 1, in <module> from django.contrib.auth.admin import User File "/Users/alexarias/PycharmProjects/ContratRestAPI/venv/lib/python3.6/site-packages/django/contrib/auth/admin.py", line 7, in <module> from django.contrib.auth.forms import ( File "/Users/alexarias/PycharmProjects/ContratRestAPI/venv/lib/python3.6/site-packages/django/contrib/auth/forms.py", line 120, in <module> class UserChangeForm(forms.ModelForm): File "/Users/alexarias/PycharmProjects/ContratRestAPI/venv/lib/python3.6/site-packages/django/forms/models.py", line 247, in __new__ opts.field_classes) File "/Users/alexarias/PycharmProjects/ContratRestAPI/venv/lib/python3.6/site-packages/django/forms/models.py", line 166, in fields_for_model formfield = f.formfield(**kwargs) File "/Users/alexarias/PycharmProjects/ContratRestAPI/venv/lib/python3.6/site-packages/django/db/models/fields/related.py", line 1579, in โฆ -
Using variable in views when running get via Ajax
I'm unable to access variable the variable solo in my coordinates function. The debug statement "solo used:" outputs "none". What do I need to do to make this work? Thanks a mil for your thoughts. in views.py def go(request): print "go executing" lat = request.GET.get('latitude', None) lng = request.GET.get('longitude', None) if not lat or not lng: print "ERROR: BAD URL PARAMETERS" # call the dronekit module we wrote before solo = drone.drone() print "solo instantiated: ", solo solo.takeoff() solo.flyTo(lat,lng, 60) resp = "Arrived and landed. <br> <a href=/rtl>Return Home</a>" request.session['solo'] = "hello" return HttpResponse(resp) def coordinates(request): #print "Request: ", request #if request.method == 'GET': solo = request.session.get('solo') print "solo used: ", solo # print "made it to views.py, and lat: ", solo.getlat(), ". lng: ", solo.getlng() #print "lat: ", lat, ". lng: ", lng #lat1 = fly_drone.getlat() #lat2 = fly_drone.getlng() #print "lat1: ", lat1, ". lat2: ", lat2 return HttpResponse('check') Note that I'm calling coordinates from map.js via ajax: function refreshData() { x = 5; setTimeout(refreshData, x*1000); console.log("refreshing now"); $.ajax({ url: '/coordinates/', type: 'get', success: function(data){ //alert(data); }, failure: function(data){ //alert('Got an error dude'); } }) Note that I do have session serializer on in settings.py: SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer' -
Minimal example of uWSGI's shared memory?
Does anyone have a minimal, working example of how to use uWSGI to share memory across requests in say Django? I have a large file in proprietary format (not database-compatible) that I need to load for each request. An instagram post got me thinking. It states: For the application server, we use uWSGI with pre-fork mode to leverage memory sharing between master and worker processes. How would you set something like that up? Would it suit my purposes?