Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Celery running task at specific time
I'm trying to run celery task at specific time every day. I'm stuck with periods via crontab. For example: tasks.py @task def every_min_task(): print('Hello, it\'s every minute task!') @task def another_one(): print('Hello specific time task!') celery.py ... @app.on_after_configure.connect def setup_periodic_tasks(sender, **kwargs): sender.add_periodic_task( crontab(), # run every minute every_min_task.s() ) sender.add_periodic_task( crontab(hour=22, minute=30), another_one.s() ) First task with "crontab()" w/o parametrs works fine, but with specific time not. What do i wrong? Timezone is ok. At least in logs i see my current time. -
Reading Excel File in Django uploaded using html form
I am learning django framework and trying to read an excel file I want to upload file using html form(POST Method) and want to read in python for calculations so what should I do really confused ? -
Multiple arguments with values to custom management command
How do I pass multiple arguments with values, from command line, to a custom django management command? def add_arguments(self, parser): parser.add_argument('str_arg1', nargs='+') parser.add_argument('int_arg2', nargs='+', type=int) When I run: ./manage.py my_command str_arg1 value int_arg2 1 --settings=config.settings.local I get the following values in options: options['str_arg1'] = ['str_arg1', 'value', 'int_arg2'] options['int_arg2'] = [1] Tried searching in documentation and online for a solution and multiple ways of passing the arguments with no luck. Django version is 1.10. Thanks -
How to use django-tls in Django unit tests
I'm trying to write some unit tests on a Django (I'm using Django==1.9.12) application that uses django-tls, but I always get this exception: RuntimeError: no object bound to request. My code looks like this: settings.py: As in django-tls doc I added the line 'tls.TLSRequestMiddleware' to my MIDDLEWARE_CLASSES: MIDDLEWARE_CLASSES = [ 'django.middleware.security.SecurityMiddleware', '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', 'tls.TLSRequestMiddleware', ] I wrote a method to test it on a module called utils.py: from tls import request def print_tls_found_by_django_tls(): """ Just print the request instance found by django-tls. :return: """ print(request) On my test_utils.py I have tried to follow the Werkzeug test utilities because Werkzeug is what django-tls use to discover the request instance. So I coded something like this for testing that: from werkzeug.test import EnvironBuilder from django.test import TestCase from example_app.utils import print_tls_found_by_django_tls class TestUtils(TestCase): def setUp(self): self.build_tls_request() def test_print_tls_found_by_django_tls(self): print_tls_found_by_django_tls() def build_tls_request(self): return EnvironBuilder(method='GET').get_request() but then the exception is there: (venv) vladir@vladir:~/work/project_example_all/example/example_app$ coverage run ./manage.py test example_app.tests.TestUtils.test_print_tls_found_by_django_tls Creating test database for alias 'default'... E ====================================================================== ERROR: test_print_tls_found_by_django_tls (affiliate_tracking.tests.test_utils.TestUtils) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/vladir/work/project_example_all/example/venv/lib/python3.5/site-packages/werkzeug/local.py", line 70, in __getattr__ return self.__storage__[self.__ident_func__()][name] KeyError: 140239354230528 During handling of the above exception, another exception occurred: Traceback (most recent call last): … -
Using the Django Admin Console with a Custom Backend in Rest Framework
I have built my entire app using the Django Rest Framework so far with a custom authentication backend. Up until now I have not needed to use the django admin console thus never really thought about it but now would like to be able to see/add some data through the admin console. The problem is is that my custom authentication gets in the way of the admin console loading (I verified this by removing my custom backend and navigating to the admin console, which worked). this there anyway that I can choose the default backend strictly for the admin console or exclude the admin console from my current custom backend? From what I have read so far here on SO and other websites has not fit my need quite right. -
Get JSON data from Django service
I'm complety new on django and python. Now I'mtriying to develop a simple service. This is the idea: I send 3 parameters from JS to Django by POST, (from another domain, CORS) in Django, python process the data and return me JSON, that all. Why have I do that!? , because I need special functions available on pyhon: Statistics. This is the code that I begin: urls.py from django.conf.urls import url from django.contrib import admin from . import controlador #este sisi urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^get_weibull/', controlador.get_data_weibull)] controlador.py from django.shortcuts import render from django.http import HttpResponseRedirect from django.shortcuts import render_to_response import numpy as np import matplotlib.pyplot as plt def weib(x,n,a): return (a / n) * (x / n)**(a - 1) * np.exp(-(x / n)**a) def get_data_weibull(self): a = 5. # shape s= np.random.weibull(a, 1000) x = np.arange(1,100.)/50. count, bins, ignored = plt.hist(np.random.weibull(5.,1000)) x = np.arange(1,100.)/50. scale = count.max()/weib(x, 1., 5.).max() plt.plot(x, weib(x, 1., 5.)*scale) ax = plt.gca() line = ax.lines[0] return render_to_response(line.get_xydata()) This is very simply on codeigniter or laravel. but I dont know how begin this on django. How Can I do that? Thanks! Rosie -
Reverse for 'detail' with arguments '('',)' and keyword arguments '{}' not found. 1
In views.py the details function def detail(request, movie_id): if not request.user.is_authenticated(): return render(request, 'movies/login.html') else: user = request.user #picture = get_object_or_404(Picture, pk=picture_id) #getting details from omdbapi bb = str(movies.ix[movies['movie_id'] == movie_id ]['title']).split() q = bb.index('Name:') bb = ' '.join(bb[1:q]) item = ia.search_movie(bb)[0] print("Name in item is " + str(item)) name = str(item) ll = name.split() #ll = '+'.join(ll) movie_url = url + '+'.join(ll) movie_url += "&plot=full" print movie_url content = urllib2.urlopen(movie_url).read() jsontopython = json.loads(content) #Values passed to details.html file plot = jsontopython['Plot'] writers = jsontopython['Writer'] producers = jsontopython['Production'] actors = jsontopython['Actors'] director = jsontopython['Director'] awards = jsontopython['Awards'] runtime = jsontopython['Runtime'] genre = jsontopython['Genre'] #movies similar to this movie. similar_movies = cf.get_similar_movies(movie_id) return render(request, 'movies/detail.html', {'similar_movies':similar_movies,'plot':plot,'writers':writers,'producers':producers, 'actors':actors,'director':director,'awards':awards,'runtime':runtime,'genre':genre,'picture':picture}) This is my urls.py urlpatterns = [ url(r'^$', views.index, name='index'), url(r'^register/$', views.register, name='register'), url(r'^login_user/$', views.login_user, name='login_user'), url(r'^(?P<movie_id>[0-9]+)/$', views.detail, name='detail'), url(r'^logout_user/$', views.logout_user, name='logout_user'), ] This is my index.html page {% for picture in top_movies %} <div class="col-sm-4 col-lg-2"> <div class="thumbnail"> <a href="{% url 'movies:detail' movie.id %}"> <img src="{% static "movies/images/images2/" %}{{picture}}" alt="Hi!" class="img-responsive" />< </a> <div class="caption"> <h4>{{ picture }}</h4> </div> </div> </div> {% endfor %} And this is my models.py from django.contrib.auth.models import Permission, User from django.db import models from decimal import Decimal class … -
Django: Is it necessary to call select_for_update for just created object in atomic transaction?
I have a view with atomic transaction, where one object is created then updated: def buy(request): with transaction.atomic(): # get request.user for update user = User.objects.select_for_update().get(id=request.user.id) user.order_count += 1 # get other stuff for update items = Item.objects.select_for_update().filter(sold=False) items.update(user=user) # DO I NEED select_for_update SOMEWHERE HERE FOR NEXT UPDATE? new_sell = Sell.objects.create(user=user) # some_operations() new_sell.some_field = something new_sell.save() HttpResponse('Done') Is it safe to update newly created objects without select_for_update() in atomic transactions? Or how do normal people implement select_for_update in such cases? I guess, this will be 100% safe, but does not look like a good plan: new_sell = Sell.objects.create(user=user) sell = Sell.objects.select_for_update().get(id=new_sell.id) # Now we can do everything with sell object -
How to do a FOR or loop that start on X and end Y index of a list on Django Template Languge?
For example i have a list of 10 objects but i just want to get last 5 or the first 5 objects. {% for x in objects %} .....first 5 objects...... {% endfor %} {% for x in objects %} .....last 5 objects...... {% endfor %} -
Django Oscar elastic search not indexing
I just add the config from Haystack docs, HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', 'URL': 'http://127.0.0.1:9200/', 'INDEX_NAME': 'haystack', }, } I am using, django-haystack==2.5.1 elasticsearch==5.0.1 django-oscar==1.4 Django==1.9.12 When i run rebuild_index its skipping all the models , not indexing I have not modified oscar's code at all OSCAR_SEARCH_FACETS = { 'fields': OrderedDict([ ('product_class', {'name': ('Type'), 'field': 'product_class'}), ('rating', {'name': ('Rating'), 'field': 'rating'}), ]), 'queries': OrderedDict([ ('price_range', { 'name': ('Price range'), 'field': 'price', 'queries': [ # This is a list of (name, query) tuples where the name will # be displayed on the front-end. (('0 to 20'), u'[0 TO 20]'), (('20 to 40'), u'[20 TO 40]'), (('40 to 60'), u'[40 TO 60]'), (('60+'), u'[60 TO *]'), ] }), ]), } -
500 internal server error mod_wsgi apache "importerror: No Module named 'django'
Issues running django and apache2/mod_wsgi. I keep getting 500 Internal Server Error. I have tried many combinations of fixes to which none have worked. Any help is greatly appreciated. This is my setup: Ubuntu 16.04 django 1.10.5 apache 2.4.18 python 3.4(virtualenv) libapache2-mod-wsgi-py3 My folder structure is: /home/user/site/venv (virtualenv folder) bin include lib /home/user/site/mysite |- manage.py static mysite |__init__.py |settings.py |urls.py |wsgi.py site.conf <VirtualHost *:80> WSGIDaemonProcess myproject python-home=/home/user/site/venv python-path=/home/user/site/mysite WSGIProcessGroup myproject WSGIScriptAlias / /home/user/site/mysite/mysite/wsgi.py Alias /static /home/user/site/mysite/static <Directory /home/user/site/mysite/static> Require all granted </Directory> <Directory /home/user/site/mysite/mysite> <Files wsgi.py> Require all granted </Files> </Directory> </VirtualHost> wsgi.py import os from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") application = get_wsgi_application() apache2/error.log [mpm_event:notice] [pid 8908:tid 140560009164672] AH00491: caught SIGTERM, shutting down [wsgi:warn] [pid 9047:tid 139761898837888] mod_wsgi: Compiled for Python/3.5.1+. [wsgi:warn] [pid 9047:tid 139761898837888] mod_wsgi: Runtime using Python/3.5.2. [mpm_event:notice] [pid 9047:tid 139761898837888] AH00489: Apache/2.4.18 (Ubuntu) mod_wsgi/4.3.0 Python/3.5.2 configured -- resuming normal operations [core:notice] [pid 9047:tid 139761898837888] AH00094: Command line: '/usr/sbin/apache2' [wsgi:error] [pid 9049:tid 139761776183040] mod_wsgi (pid=9049): Target WSGI script '/home/user/site/mysite/mysite/wsgi.py' cannot be loaded as Python module. [wsgi:error] [pid 9049:tid 139761776183040] mod_wsgi (pid=9049): Exception occurred processing WSGI script '/home/user/site/mysite/mysite/wsgi.py'. [wsgi:error] [pid 9049:tid 139761776183040] Traceback (most recent call last): [wsgi:error] [pid 9049:tid 139761776183040] File "/home/user/site/mysite/mysite/wsgi.py", line 12, in <module> [wsgi:error] … -
Ordering queryset by filtered child objects
I have the following (simplified) data model, see visual representation below the post: Articles, which have Attributes Attributes refer by PK to a Type, which have a field code Attributes have a field value The value refers to the field uuid in another model called Record, which also has a field sorting_code I now want to return a list of articles in a certain ordering, using pagination. I am using a default ViewSet for it. The pagination forces me to do the ordering in database, instead of later in Python. However, I cannot seem to find the correct ordering clause that orders these articles. What I need to do is: Fetch the Attribute with a specific type Look up the values in those Attributes in the Record table Order the articles based by sorting_code The following SQL query does the job (for all articles): SELECT art.order_id, art.uuid, att.value, mdr.code, mdr.name, mdr.sorting_code FROM ow_order_article art INNER JOIN ow_order_attribute att ON att.article_id = art.uuid INNER JOIN ow_masterdata_type mdt ON att.masterdata_type_id = mdt.uuid INNER JOIN ow_masterdata_record mdr ON att.value = mdr.uuid WHERE mdt.code = 'article_structure' ORDER BY mdr.sorting_code, mdr.code What would be the correct way to get this ordering in a queryset in … -
django template url from js file
In django project I have urls.py like url(r'^data/$', get_data, name='data'), I can add in my template data.html like <a href='{% url 'data' %}'>Create New Data</a> and it works fine. When I click on link it displays localhost:/data. But I am displaying table dynamically using jquery and datatable and in data.js and I am able to make clickable table cell using $('#table').DataTable( { "columnDefs": [ { "render": function (data, type, row){ return "<a href='blawblawblaw'>Click cell</a>"; }, ] }) But can I pass url through above return statement? something like return "<a href='{% url 'data' %}'>Click cell</a>"; If I try with above I get error 404 error with The current URL, {% url, didn't match any of these. If I try like this return "<a href='{% url \"data\" %}'>Click cell</a>"; I get The current URL, {% url "data" %}, didn't match any of these. -
how to copy url without "www" to the url with "www"?
I'm hosting a Django project, let's say the name is www.example.com, when an user search for example.com/subname to redirect to www.example.com/subname. Unfortunalety, right now it's redirecting to www.example.com without adding the "subname" part to my url. I have my domain name on infomaniak which redirects example.com to www.example.com, the hosting is on pythonanywhere where it handles my Django project. How can I achieve the case where what's put after domain name url is kept and used to redirect to the one with www. ? (For my Django project I'm not using apache nor nginx, so where is the htaccess file if the changes has to be made there ?) -
How do I display a single object with TemplateView?
I am working on creating an "About" app for my website that dynamically generates "About" pages. For the index page of the app, I specifically want it to display the "About Us" page with a subsequent list of pages in the app. What I am struggling to figure out is how do I access that single object from my queryset and display it through a TemplateView? Here is the current code for the view: class AboutIndexView(TemplateView): template_name = 'about/about.html' def get_context_data(self, **kwargs): context = super(AboutIndexView, self).get_context_data(**kwargs) context['about_page'] = Page.objects.all().exclude(title='About Us') context['about_us'] = Page.objects.filter(title='About Us') return context Here is the current code for the template: {% for page in about_us %} <div class="text-center"> <h3>{{ page.title }}</h3> </div> {{ page.body|safe|linebreaks }} {% endfor %} Just to reiterate the question, how would I change my view code so that I no longer have to create a for loop in my template code, but just be able to display the "About Us" directly? -
TypeError: Object of type 'Category'(model) is not JSON serializable
Model class: class Category(models.Model): name = models.CharField(max_length=200) def __str__(self): return self.name The controller that works with model: @login_required def categories_ajax(request): categories = Category.objects.all() cats = serializers.serialize('json', categories) return HttpResponse( json.dumps(cats), content_type="application/json" ) TypeError: Object of type 'Category' is not JSON serializable But in response in JavaScript with next code: $.getJSON( "/categories/ajax/", function( json ) { var src = JSON.parse(json); console.log(src); In the console I have "Array [ Object, Object ]". Where is problem? I cannot understand -
Python ldap OSX - ValueError: option error
Im trying to setup python-ldap on OSX Serria. When i try use the module (which works in my live env running on centos) I get the below error, which upon searching looks to be something to do with the install of open ldap or python-ldap on OSX, but I'm yet to find an article that explains how to fix it. thus far i have installed openldap via homebrew which has not fixed the issue: error: Traceback (most recent call last): File "/usr/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 42, in inner response = get_response(request) File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response response = self._get_response(request) File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/views.py", line 47, in inner return func(*args, **kwargs) File "/usr/local/lib/python2.7/site-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper return view(request, *args, **kwargs) File "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py", line 149, in _wrapped_view response = view_func(request, *args, **kwargs) File "/usr/local/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "/usr/local/lib/python2.7/site-packages/django/contrib/auth/views.py", line 81, in login if form.is_valid(): File "/usr/local/lib/python2.7/site-packages/django/forms/forms.py", line 169, in is_valid return self.is_bound and not self.errors File "/usr/local/lib/python2.7/site-packages/django/forms/forms.py", line 161, in errors self.full_clean() File "/usr/local/lib/python2.7/site-packages/django/forms/forms.py", line 371, in full_clean self._clean_form() File "/usr/local/lib/python2.7/site-packages/django/forms/forms.py", line 398, in _clean_form cleaned_data … -
django get fields based on what the user provides
models.py from __future__ import unicode_literals from django.db import models # Create your models here. class gestao(models.Model): Computador = models.CharField(max_length=64,blank=False) Ip = models.CharField(max_length=16,blank=False) So = models.CharField(max_length=8,blank=False) Ultimo_Env = models.DateTimeField(blank=False) Data_Actual = models.DateTimeField(blank=False) Idle = models.BooleanField() MacAddress= models.CharField(max_length=24,blank=False) Timestamp = models.IntegerField() Sala = models.CharField(max_length=10) Views.py from django.shortcuts import render from istPCM.quickstart.models import gestao from rest_framework import viewsets from istPCM.quickstart.serializers import gestao_Serializer from rest_framework.decorators import detail_route # Create your views here. class gestao_ViewSet(viewsets.ModelViewSet): """ API endpoint that allows users to be viewed or edited. """ queryset = gestao.objects.all() #.order_by('-date_joined') serializer_class = gestao_Serializer @detail_route(methods=['GET'],url_path='(?P<labs>[a-z0-9]+)') def index(self,request,labs): lab = Gestao.objects.filter(Sala=labs) gestao_as_json = serializers.serialize('json',lab) return HttpResponse(gestao_as_json, content_type='json') I'm new to django and i've got a external website , and i'm trying to build a search like i used to do in mysql the user can give the informations that he wants and the django sends the results of the search back Ex : the user check's Idle and says like 02/01(1 of February) to 02/03(3º of February). the server is supost to give me evry results that has that condition Can someone help me i'm kind of getting confused.. help -
Inheritance models in Django 1.8.2 to Django 1.11
I have the task of convert the project from django version 1.8.2 to version 1.11. Faced a problem with which I can not cope. That model of tables, which worked excellently in 1.8.2, stopped working in version 1.11, and falls out with an error: core.CarModel.manufacture: (models.E006) The field 'manufacture' clashes with the field 'manufacture' from model 'core.page'. Apparently this is due to the inheritance of models, since the project is old I can not fundamentally change the scheme of tables, please tell me how to get out of this situation. Thank you in advance for your help. I have reproduced the scheme of models, which works fine on 1.8.2 and stops working on 1.11: # -*- coding:utf-8 -*- from django.db import models from django.contrib.contenttypes.models import ContentType class InheritanceCastModel(models.Model): real_type = models.ForeignKey(ContentType, editable=False) def save(self, *args, **kwargs): if not self.id: self.real_type = self._get_real_type() super(InheritanceCastModel, self).save(*args, **kwargs) def _get_real_type(self): return ContentType.objects.get_for_model(type(self)) def cast(self): return self.real_type.get_object_for_this_type(pk=self.pk) class Meta: abstract = True class Page(InheritanceCastModel): title = models.CharField(max_length=512, verbose_name=u'Title', blank=True) class Manufacture(Page): ru_title = models.CharField(max_length=128, verbose_name=u'RU Title') class CarModel(Page): manufacture = models.ForeignKey(Manufacture, verbose_name=u'Manufacture') ru_title = models.CharField(max_length=64, verbose_name=u'Ru Title') -
condition indo queryset does not work
i want to add a condition into a queryset of a form , this is my source code : class ContainerForm(forms.ModelForm): vehicle = forms.ModelChoiceField(required=False,queryset=Vehicle.objects.filter(id = vehicle.id),widget=forms.Select(attrs={'class':'form-control'})) but the debuging said that vehicle.id is not defined -
I am not sure what is wrong :(
I am really, really new into coding (like literally started a few days ago, to learn some things by myself). So yeah, I have written a small code, just for fun, and I am trying to convert into a .exe with pyintaller, but I am not sure why, it is not working. The dist folder is empty and this is the cmd process, can u help with some advice, but please keep it simple :) Thanks a lot! C:\Users\el-aa\Desktop\New folder>pyinstaller 123.py 103 INFO: PyInstaller: 3.2.1 103 INFO: Python: 3.6.1 104 INFO: Platform: Windows-10-10.0.14393-SP0 108 INFO: wrote C:\Users\el-aa\Desktop\New folder\123.spec 109 INFO: UPX is not available. 111 INFO: Extending PYTHONPATH with paths ['C:\Users\el-aa\Desktop\New folder', 'C:\Users\el-aa\Desktop\New folder'] 111 INFO: checking Analysis 111 INFO: Building Analysis because out00-Analysis.toc is non existent 111 INFO: Initializing module dependency graph... 115 INFO: Initializing module graph hooks... 116 INFO: Analyzing base_library.zip ... Traceback (most recent call last): File "E:\Software\Python\Scripts\pyinstaller-script.py", line 11, in load_entry_point('PyInstaller==3.2.1', 'console_scripts', 'pyinstaller')() File "e:\software\python\lib\site-packages\PyInstaller__main__.py", line 90, in run run_build(pyi_config, spec_file, **vars(args)) File "e:\software\python\lib\site-packages\PyInstaller__main__.py", line 46, in run_build PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs) File "e:\software\python\lib\site-packages\PyInstaller\building\build_main.py", line 788, in main build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build')) File "e:\software\python\lib\site-packages\PyInstaller\building\build_main.py", line 734, in build exec(text, spec_namespace) File "", line 16, in File "e:\software\python\lib\site-packages\PyInstaller\building\build_main.py", … -
Make a list and QuerySet comparable
First I know that similar questions have been asked ( I looked at them) but none of them answered my question. If this question has been answered please send me the link and I will delete this one. So I have this function in which I would like to compare how often a Word has been used in both lists/QuerySets. Since the don't have the same structure I cannot do that. productArr = self.tags.all() # is a QuerySet CustomerArr = self.user.userprofile.I_want.split(",")[:3] def func(a, b): global favVal favVal = 0 for i in a: if i in b: #print('hey') favVal += 1 return False func(productArr, CustomerArr) so I tried to productArrlist = list(productArr) and similar things to make those two comparable but it did not work. I hope somebody can help me out here. Regards -
Is it possible to submit a GET form to two different views with two buttons in django?
I have a get form that works well on one view. http://myurl.com/myapp/filter_objects/?risk__worktask=1&craft=3 I have another view to export this filtered list to pdf. For now i'm storing the results in session and accessing list from there in my pdf view, but ideally i would like to pass the filter parameters from the GET form directly to the export_to_pdf view. Is that possible in django ? [ to have a given GET form send to two different urls with two submit buttons ? Would be great ! Thanks ! Here's my form <form method="get"> <div class="well"> <h4 style="margin-top: 0">Filter Objects</h4> <div class="row"> <div class="form-group col-sm-4 col-md-3"> {{ filter.form.risk__worktask.label_tag }} {% render_field filter.form.risk__worktask class="form-control" %} </div> <div class="form-group col-sm-4 col-md-3"> {{ filter.form.craft.label_tag }} {% render_field filter.form.craft class="form-control" %} </div> </div> <button type="submit" class="btn btn-primary"> <span class="glyphicon glyphicon-search"></span> Search </button> </div> <div class="well"> <h4 style="margin-top: 0">Filtered Ratings: {{ filter.qs.count }}</h4> <a href="{% url 'myapp:export_ratings_to_pdf_by_worktask' %}"> <button type="button" class="btn btn-success">Export Filtered List ({{ filter.qs.count }} items)</button> </a> </div> -
How to create sub-domain for local host in django app?
How to create sub-domain in django app. Basically i want give a sub-domain to every new register user like http://username.127.0.0.1:8000 so how to change the url -
specify upload destination with multiple LIBCLOUD_PROVIDERS settings
I have to fileField I want to have a different cloud storage for each How to specify the upload destination on the field settings level. Doc link: http://django-storages.readthedocs.io/en/latest/backends/apache_libcloud.html