Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Remote username Django
I need to get remote username in django. I mean the username logged into windows. Like getting logged in username in views.py user=request.user. Is there any command to get remote username? -
django filters objects from different model
this is my django models: class Videos(models.Model): Title = models.CharField(max_length=100, unique=False, help_text='video title') Description = models.TextField(null=True, unique=False, blank=True) Tags = models.CharField(max_length=250, unique=False, blank=True) Category = models.CharField("Category", max_length=32, default='28', choices=CATEGORIES, null=False, blank=False) Language = models.CharField("Language", max_length=32, default='EN', choices=LANGUAGES, null=False, blank=False) file = models.FileField(upload_to='videos/', null=True, blank=False, validators=[FileExtensionValidator(allowed_extensions=['mp4'])] ) Playlist = models.CharField(max_length=100, unique=False) title_gen = models.BooleanField(default=False) class TitleVideo(models.Model): video = models.ForeignKey(Videos, related_name='video_id', null=False, blank=False, on_delete=models.CASCADE) converted = models.BooleanField( default=False, help_text='video has ben converted (True | False)') publicato = models.BooleanField( default=False, help_text='video has ben published (True | False)') i need to get all Videos who have TitleVideo.converted = false and Videos.title_gen =True, how i can do this ? -
django.db.utils.OperationalError: no such column: <app>_connections_friends.connections_id
I have an User object class User(AbstractBaseUser, PermissionsMixin, Base): username = models.CharField(db_index=True, null=False, unique=True, max_length=255) mobile = PhoneNumberField(db_index=True, null=False, unique=True) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) is_active = models.BooleanField(default=False) And I have the following Connections object class Connections(Base): owner = models.OneToOneField(User, on_delete=models.CASCADE, null=True) friends = models.ManyToManyField(User, related_name='friend_set', symmetrical=True) followers = models.ManyToManyField(User, related_name="follower_set", symmetrical=False) followings = models.ManyToManyField(User, related_name="following_set", symmetrical=False) When I run the following line, sender = User.objects.get(id=kwargs.get('sender_id')) receiver = User.objects.get(id=kwargs.get('receiver_id')) sender_connections, created = Connections.objects.get_or_create(owner=sender) sender_connections.friends.add(receiver) I get the following error, django.db.utils.OperationalError: no such column: <appname>_connections_friends.connections_id I'm not sure what am I doing wrong here? -
Prevent users from creating Django account with username on list
In Django Rest Framework, I've got a post model that can be filtered by both usernames from my user object, and country names from a country objects. It just adds a ?search= to the end of the API. From the frontend, it uses the same form to add this query onto the end of the url. I'd like to avoid confusion of returning both country names and user names that are the same. For example, if someone searched for Ireland, by preventing users from making an account with the username Ireland, it would only return Posts with country Ireland associated with the post (ManyToMany relationship to posts). Is anything like this possible outside of creating a user for every country? -
AttributeError django
I've just create django project and added app. Runserer was fine first time, but I added some code and get huge amount of errors. This is the view in the new app named HotelAuth. from django.http import JsonResponse def test(request): context = { 'tittle': 'some tittle', 'description': 'descr' } return JsonResponse(context) Installed Apps INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.HotelAuth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'HotelAuth', ] urls of project from django.contrib import admin from django.urls import path from django.contrib.HotelAuth.views import test urlpatterns = [ path('admin/', admin.site.urls), path('', test) ] That is all i modified, and get errors in pictire -
Page not found media docfiles
hi i'm try open docx file with the path absolute, someone files open ok but others files dont open and get the error: Page not found (404) the path is this: media/gestionDocumental/Operativos/Produccion/PR/01 Planificacion y prod de balanceado/ANEXO 4._Encendido y apagado de la mezcladora #2.docx this path is correct and the files get this name, but i dont understan why dont open this file, this i my code: function openFile(path){ console.log(path); var hostName=window.location.host+"/" var linkDoc="http://"+hostName+path; window.open(linkDoc, '_blank', 'location=yes,height=600,width=900,scrollbars=yes,status=yes'); }//end function openFile this code use in javascript to open and force donwload this file but get the error.. please any suggest.. or idea thanks..!! -
Django Rest Framework url_pattern of @action
I need to pass instance id after last / of my @action name method, and I seriously have no idea how... I have a UserViewSet, which url to access list is : /users/, then i have action called favorite_posts, which is detail=False because I'm filtering by current logged user, and the action refer to user posts, I wanna be able to pass the post_id like /users/favorite_posts/1/, because in this case it's more friendly to me than /users/1/favorite_posts/ which I could obtain setting detail=True. Is there any way to do that? -
Django: Display different data from a view based on URL using if elif
I have about 1000 records worth of data and I would like to display the subsets of that data in the same template file based on category. I am having trouble finding a solution that really works. Below is what I have so for but I am pretty sure there is a much more efficient way to do this. View def man_org_list(request): manufacturers = Organization.objects.filter(member__member_flag=1, member__member_type='Manufacturer').order_by('id') suppliers = Organization.objects.filter(member__member_flag=1, member__member_type='Supplier').order_by('id') distributor = Organization.objects.filter(member__member_flag=1, member__member_type='distributor').order_by('id') return render(request, 'profiles/man_dash.html', {'man': manufacturers, 'sup': suppliers, 'dist': distributor}) urls.py urlpatterns = [ url(r'^$', views.org_list, name='org_list'), url(r'^(?P<id>\d+)/$', views.org_details, name='org_details'), url(r'^man_dash/', views.man_org_list, name='man_org_list') ] Part of the code I am trying to change base on category: {% if request.get_full_path == '/profiles/man_dash/manufacturers/' %} {% for org in man %} <tr> <th scope="row">{{ org.id }}</th> <td>{{ org.org_name }}</td> <td>{{ org.org_type }}</td> {% for member in org.member.all %} <td>{{ member.member_flag }}</td> {% endfor %} {% for c_score in org.c_score.all %} <td>{{ c_score.completeness_score }}%</td> {% endfor %} <td><a href="{% url 'org_details' org.id %}" target="_blank">View</a></td> </tr> {% endfor %} {% endif %} As you can see in the snippet I am using request.get_full_path to match the url path to display the data. However, using this approach I would have to copy over … -
PosGis and Django-Tenants
(Using the library django-tenants for tenant separated multi-tenancy) For PostGis support the docs say to add ORIGINAL_BACKEND = "django.contrib.gis.db.backends.postgis". I have this, however, when I go to create a new tenant I get the following error: Traceback (most recent call last): File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\celery\app\trace.py", line 382, in trace_task R = retval = fun(*args, **kwargs) File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\celery\app\trace.py", line 641, in __protected_call__ return self.run(*args, **kwargs) File "C:\Users\Cole\Documents\GitHub\Elevate-RA-Django-App\returns_app\apps\tenant_stores\tasks.py", line 28, in create_tenant_task tenant.save() File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\django_tenants\models.py", line 93, in save self.create_schema(check_if_exists=True, verbosity=verbosity) File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\django_tenants\models.py", line 143, in create_schema verbosity=verbosity) File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\django\core\management\__init__.py", line 141, in call_command return command.execute(*args, **defaults) File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\django\core\management\base.py", line 335, in execute output = self.handle(*args, **options) File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\django_tenants\management\commands\migrate_schemas.py", line 63, in handle executor.run_migrations(tenants=tenants) File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\django_tenants\migration_executors\standard.py", line 15, in run_migrations run_migrations(self.args, self.options, self.codename, schema_name, idx=idx, count=len(tenants)) File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\django_tenants\migration_executors\base.py", line 34, in run_migrations MigrateCommand(stdout=stdout, stderr=stderr).execute(*args, **options) File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\django\core\management\base.py", line 335, in execute output = self.handle(*args, **options) File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\django\core\management\commands\migrate.py", line 77, in handle connection.prepare_database() File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\django\contrib\gis\db\backends\postgis\base.py", line 26, in prepare_database cursor.execute("CREATE EXTENSION IF NOT EXISTS postgis") File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\django\db\backends\utils.py", line 100, in execute return super().execute(sql, params) File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\django\db\backends\utils.py", line 68, in execute return self._execute_with_wrappers(sql, params, many=False, executor=self._execute) File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\django\db\backends\utils.py", line 77, in _execute_with_wrappers return executor(sql, params, many, context) File "c:\users\cole\appdata\local\programs\python\python36-32\lib\site-packages\django\db\backends\utils.py", line 85, in _execute return self.cursor.execute(sql, params) … -
Django restpagination
I'm trying to paginate using django rest framework. Here is my code. my views.py: class SmallPagesPagination(PageNumberPagination): page_size = 6 class ExceptionModelView(generics.ListAPIView): queryset = ExceptionModel.objects.all() pagination_class = SmallPagesPagination def get(self, request, *args, **kwargs): serializer = ExceptionModelSerializer(queryset, many=True) page = self.paginate_queryset(serializer.data) return self.get_paginated_response(page) in settings.py: REST_FRAMEWORK = { 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', } my error: Internal Server Error: /app/exceptions/ Traceback (most recent call last): File "/home/danee/enviroments/edu/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner response = get_response(request) File "/home/danee/enviroments/edu/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/danee/enviroments/edu/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) TypeError: __init__() takes 1 positional argument but 2 were given [29/Nov/2018 16:39:49] "GET /app/exceptions/ HTTP/1.1" 500 16023 -
How to import Django model in Beautiful Soup
I have problem to import django model to script in python (Beautiful Soup). The script name scrapy_link.py and try this from app.appmod.models import Article. And I have error: from app.appmod.models import Article ModuleNotFoundError: No module named 'app.appmod' My folder structure look this: project myvenv app app settings.py, urls,py, init.py, etc. appmod models.py, views.py, admin.py, etc. scrapy_link.py -
Django order of message tags
I wonder if it is possible to change the order of the message tags of a django message with extra tags. from django.contrib import messages messages.success(request, 'success message', extra_tags='safe') And in my template i use {% if messages %} {% for message in messages %} <div class="alert alert-{{ message.tags }}"> {% if 'safe' in message.tags %}{{ message|safe }}{% else %}{{ message }}{% endif %} </div> {% endfor %} {% endif %} With this i the class of the div will be: <div class="alert alert-safe success"> but i want to have the two tags switched, so that i can use the bootstrap class. Is this possible? -
How to get values from Raw Html for in Django
This maybe stupid. But I'm finding problem in it. I'm working with Django, I have read docs. But for the forms, there is class. If I use this then a form is generated in the view, But actually I hardcoded the entire form, I just need to take the values from it. Like PHP. How to achieve this, I don't wanna Django to generate my form. Thanks in advance! -
Chromedriver doesn't open on windows?
I have a django application that it uses selenium and chromedriver on ubuntu when I try to open the application from windows the chromedriver doesn't open -
Django : cannot find model when inserting values to model from html form?
I am trying to insert values to sqlite database using basic django forms. These are my Settings Models.py class Book(models.Model): def get_absolute_url(self): return reverse ('books:detail',kwargs={'pk':self.pk}) def __str__(self): return self.name+ '-'+self.author name = models.CharField(max_length=120) author = models.CharField(max_length=120) genere = models.CharField(max_length=120) year = models.CharField(max_length=120) image = models.ImageField(upload_to='img/',null=True,blank=True) forms.py from django import forms from .models import Book SOME_CHOICES = ( ('Science fiction','Science fiction'), ('Psychology','Psychology'), ('Philosophy','Philosophy'), ('Novel','Novel'), ('Poetry','Poetry'), ) class BookForm(forms.Form): name = forms.CharField() author = forms.CharField() genere = forms.CharField(label='Text',widget= forms .Select (choices=SOME_CHOICES)) year = forms.CharField() book_image = forms.ImageField() views.py from django.shortcuts import render,redirect from books.forms import BookForm from django import forms from books.models import Book from django.forms import ModelForm from django.core.urlresolvers import reverse_lazy from django.views import generic from django.shortcuts import render from django.http import HttpResponse from .models import Book from django.views.generic import (ListView,CreateView,UpdateView,DeleteView,TemplateView) from django.template import loader from django.http import Http404 from django.views.generic.edit import CreateView from django.core.urlresolvers import reverse def Book_Create_View(request): form=BookForm(request.POST,request.FILES) if form.is_valid(): book_obj=models.Book() book_obj.name = request.POST.get("name") book_obj.author = request.POST.get("author") book_obj.genere = request.POST.get("genere") book_obj.year = request.POST.get("year") book_obj.image = request.FILES book_obj.save() return redirect('books:index') else: form = BookForm() template ='books/book_form.html' return render(request,template,{'form':form}) book_form.html {% extends 'books/base.html'%} {%block content%} <form class="form-horizontal" action="" method="post" enctype="multipart/form-data"> {% csrf_token %} {{form}} <div class="form-group"> <button type="submit" class="btn btn-sucess">Submit </button> … -
Syntax error using try: except within a for loop to handle DivideZeroError
Iterating across multiple dicts, I am trying to calculate the percentage of values from each dict, sum_allBlocks and sum_allBounds. I then add this data to a new dict as a list. Can someone help me to avoid my ZeroDivideError that I get whenever one of the values in sum_allBounds is zero? Got a syntax error when adding the try: except: inside the for loop. #Get Block% by Stand from allstands, add to daily_details as percent_allBlocks def get_flight_details(stand_data): for _key, allstands in stand_data.items(): daily_details = {} divide_allBlocks = ["{0:3.1f}%".format(a / b * 100) for a, b in zip(sum_allBlocks, sum_allBounds)] daily_details['percent_allBlocks'] = divide_allBlocks -
Django - how to print only the value of a variable
I'm working on a project for college and I'm trying to print out the value of a model in django but the result I'm getting on my webpage is ]>, lulll is name of a student. I'm trying to print out just the value without the queryset and the brackets. Below is my views.py file and my html http://prntscr.com/loko6n http://prntscr.com/lokoh6 Thank you :) -
RBAC with Django REST Framework
Any suggestions on what I should use to integrate RBAC with DRF? I have taken a look at django-rest-framework-roles and django-guardian but neither look too promising. Your feedback would be much appreciated. Thanks in advance. -
Test Django Channels
I'm writing unit tests for a project but I'm not able to figure out how to read a message from a channel after sending the message. @task(name="export_to_caffe", bind=True) def export_caffe_prototxt(self, net, net_name, reply_channel): net = yaml.safe_load(net) if net_name == '': net_name = 'Net' try: prototxt, input_dim = json_to_prototxt(net, net_name) randomId = datetime.now().strftime('%Y%m%d%H%M%S')+randomword(5) with open(BASE_DIR + '/media/' + randomId + '.prototxt', 'w+') as f: f.write(prototxt) Channel(reply_channel).send({ 'text': json.dumps({ 'result': 'success', 'action': 'ExportNet', 'name': randomId + '.prototxt', 'url': '/media/' + randomId + '.prototxt' }) }) except: Channel(reply_channel).send({ 'text': json.dumps({ 'result': 'error', 'action': 'ExportNet', 'error': str(sys.exc_info()[1]) }) }) This is the function I want to write tests for. class TestExportCaffePrototxt(unittest.TestCase): def test_task(self): net = '{"l36":{"info":{"phase":null,"type":"ReLU","parameters":0},"shape":{"input":[4096],"output":[4096]},"connection":{"input":["l35"],"output":["l37"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l36"}},"l37":{"info":{"phase":null,"type":"Dropout","parameters":0},"shape":{"input":[4096],"output":[4096]},"connection":{"input":["l36"],"output":["l38"]},"params":{"caffe":true,"rate":0.5,"trainable":false,"seed":42,"inplace":true},"props":{"name":"l37"}},"l34":{"info":{"phase":null,"type":"Dropout","parameters":0},"shape":{"input":[4096],"output":[4096]},"connection":{"input":["l33"],"output":["l35"]},"params":{"caffe":true,"rate":0.5,"trainable":false,"seed":42,"inplace":true},"props":{"name":"l34"}},"l35":{"info":{"phase":null,"type":"InnerProduct","parameters":16781312},"shape":{"input":[4096],"output":[4096]},"connection":{"input":["l34"],"output":["l36"]},"params":{"bias_filler":"constant","bias_regularizer":"None","kernel_constraint":"None","bias_constraint":"None","activity_regularizer":"None","num_output":4096,"weight_filler":"constant","kernel_regularizer":"None","caffe":true,"use_bias":true},"props":{"name":"l35"}},"l32":{"info":{"phase":null,"type":"InnerProduct","parameters":102764544},"shape":{"input":[512,7,7],"output":[4096]},"connection":{"input":["l31"],"output":["l33"]},"params":{"bias_filler":"constant","bias_regularizer":"None","kernel_constraint":"None","bias_constraint":"None","activity_regularizer":"None","num_output":4096,"weight_filler":"constant","kernel_regularizer":"None","caffe":true,"use_bias":true},"props":{"name":"l32"}},"l33":{"info":{"phase":null,"type":"ReLU","parameters":0},"shape":{"input":[4096],"output":[4096]},"connection":{"input":["l32"],"output":["l34"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l33"}},"l30":{"info":{"phase":null,"type":"ReLU","parameters":0},"shape":{"input":[512,14,14],"output":[512,14,14]},"connection":{"input":["l29"],"output":["l31"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l30"}},"l31":{"info":{"phase":null,"type":"Pooling","parameters":0},"shape":{"input":[512,14,14],"output":[512,7,7]},"connection":{"input":["l30"],"output":["l32"]},"params":{"layer_type":"2D","kernel_w":2,"stride_d":1,"pad_h":0,"stride_h":2,"pad_d":0,"padding":"SAME","stride_w":2,"kernel_d":"","caffe":true,"kernel_h":2,"pad_w":0,"pool":"MAX"},"props":{"name":"l31"}},"l38":{"info":{"phase":null,"type":"InnerProduct","parameters":4097000},"shape":{"input":[4096],"output":[1000]},"connection":{"input":["l37"],"output":["l39"]},"params":{"bias_filler":"constant","bias_regularizer":"None","kernel_constraint":"None","bias_constraint":"None","activity_regularizer":"None","num_output":1000,"weight_filler":"constant","kernel_regularizer":"None","caffe":true,"use_bias":true},"props":{"name":"l38"}},"l39":{"info":{"phase":null,"type":"Softmax","parameters":0},"shape":{"input":[1000],"output":[1000]},"connection":{"input":["l38"],"output":[]},"params":{"caffe":true},"props":{"name":"l39"}},"l18":{"info":{"phase":null,"type":"Convolution","parameters":1180160},"shape":{"input":[256,28,28],"output":[512,28,28]},"connection":{"input":["l17"],"output":["l19"]},"params":{"layer_type":"2D","stride_d":1,"pad_h":1,"kernel_constraint":"None","activity_regularizer":"None","stride_h":1,"pad_d":0,"weight_filler":"constant","stride_w":1,"dilation_d":1,"use_bias":true,"pad_w":1,"kernel_w":3,"bias_filler":"constant","bias_regularizer":"None","bias_constraint":"None","dilation_w":1,"num_output":512,"kernel_d":"","caffe":true,"dilation_h":1,"kernel_regularizer":"None","kernel_h":3},"props":{"name":"l18"}},"l19":{"info":{"phase":null,"type":"ReLU","parameters":0},"shape":{"input":[512,28,28],"output":[512,28,28]},"connection":{"input":["l18"],"output":["l20"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l19"}},"l14":{"info":{"phase":null,"type":"ReLU","parameters":0},"shape":{"input":[256,56,56],"output":[256,56,56]},"connection":{"input":["l13"],"output":["l15"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l14"}},"l15":{"info":{"phase":null,"type":"Convolution","parameters":590080},"shape":{"input":[256,56,56],"output":[256,56,56]},"connection":{"input":["l14"],"output":["l16"]},"params":{"layer_type":"2D","stride_d":1,"pad_h":1,"kernel_constraint":"None","activity_regularizer":"None","stride_h":1,"pad_d":0,"weight_filler":"constant","stride_w":1,"dilation_d":1,"use_bias":true,"pad_w":1,"kernel_w":3,"bias_filler":"constant","bias_regularizer":"None","bias_constraint":"None","dilation_w":1,"num_output":256,"kernel_d":"","caffe":true,"dilation_h":1,"kernel_regularizer":"None","kernel_h":3},"props":{"name":"l15"}},"l16":{"info":{"phase":null,"type":"ReLU","parameters":0},"shape":{"input":[256,56,56],"output":[256,56,56]},"connection":{"input":["l15"],"output":["l17"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l16"}},"l17":{"info":{"phase":null,"type":"Pooling","parameters":0},"shape":{"input":[256,56,56],"output":[256,28,28]},"connection":{"input":["l16"],"output":["l18"]},"params":{"layer_type":"2D","kernel_w":2,"stride_d":1,"pad_h":0,"stride_h":2,"pad_d":0,"padding":"SAME","stride_w":2,"kernel_d":"","caffe":true,"kernel_h":2,"pad_w":0,"pool":"MAX"},"props":{"name":"l17"}},"l10":{"info":{"phase":null,"type":"Pooling","parameters":0},"shape":{"input":[128,112,112],"output":[128,56,56]},"connection":{"input":["l9"],"output":["l11"]},"params":{"layer_type":"2D","kernel_w":2,"stride_d":1,"pad_h":0,"stride_h":2,"pad_d":0,"padding":"SAME","stride_w":2,"kernel_d":"","caffe":true,"kernel_h":2,"pad_w":0,"pool":"MAX"},"props":{"name":"l10"}},"l11":{"info":{"phase":null,"type":"Convolution","parameters":295168},"shape":{"input":[128,56,56],"output":[256,56,56]},"connection":{"input":["l10"],"output":["l12"]},"params":{"layer_type":"2D","stride_d":1,"pad_h":1,"kernel_constraint":"None","activity_regularizer":"None","stride_h":1,"pad_d":0,"weight_filler":"constant","stride_w":1,"dilation_d":1,"use_bias":true,"pad_w":1,"kernel_w":3,"bias_filler":"constant","bias_regularizer":"None","bias_constraint":"None","dilation_w":1,"num_output":256,"kernel_d":"","caffe":true,"dilation_h":1,"kernel_regularizer":"None","kernel_h":3},"props":{"name":"l11"}},"l12":{"info":{"phase":null,"type":"ReLU","parameters":0},"shape":{"input":[256,56,56],"output":[256,56,56]},"connection":{"input":["l11"],"output":["l13"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l12"}},"l13":{"info":{"phase":null,"type":"Convolution","parameters":590080},"shape":{"input":[256,56,56],"output":[256,56,56]},"connection":{"input":["l12"],"output":["l14"]},"params":{"layer_type":"2D","stride_d":1,"pad_h":1,"kernel_constraint":"None","activity_regularizer":"None","stride_h":1,"pad_d":0,"weight_filler":"constant","stride_w":1,"dilation_d":1,"use_bias":true,"pad_w":1,"kernel_w":3,"bias_filler":"constant","bias_regularizer":"None","bias_constraint":"None","dilation_w":1,"num_output":256,"kernel_d":"","caffe":true,"dilation_h":1,"kernel_regularizer":"None","kernel_h":3},"props":{"name":"l13"}},"l21":{"info":{"phase":null,"type":"ReLU","parameters":0},"shape":{"input":[512,28,28],"output":[512,28,28]},"connection":{"input":["l20"],"output":["l22"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l21"}},"l20":{"info":{"phase":null,"type":"Convolution","parameters":2359808},"shape":{"input":[512,28,28],"output":[512,28,28]},"connection":{"input":["l19"],"output":["l21"]},"params":{"layer_type":"2D","stride_d":1,"pad_h":1,"kernel_constraint":"None","activity_regularizer":"None","stride_h":1,"pad_d":0,"weight_filler":"constant","stride_w":1,"dilation_d":1,"use_bias":true,"pad_w":1,"kernel_w":3,"bias_filler":"constant","bias_regularizer":"None","bias_constraint":"None","dilation_w":1,"num_output":512,"kernel_d":"","caffe":true,"dilation_h":1,"kernel_regularizer":"None","kernel_h":3},"props":{"name":"l20"}},"l23":{"info":{"phase":null,"type":"ReLU","parameters":0},"shape":{"input":[512,28,28],"output":[512,28,28]},"connection":{"input":["l22"],"output":["l24"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l23"}},"l22":{"info":{"phase":null,"type":"Convolution","parameters":2359808},"shape":{"input":[512,28,28],"output":[512,28,28]},"connection":{"input":["l21"],"output":["l23"]},"params":{"layer_type":"2D","stride_d":1,"pad_h":1,"kernel_constraint":"None","activity_regularizer":"None","stride_h":1,"pad_d":0,"weight_filler":"constant","stride_w":1,"dilation_d":1,"use_bias":true,"pad_w":1,"kernel_w":3,"bias_filler":"constant","bias_regularizer":"None","bias_constraint":"None","dilation_w":1,"num_output":512,"kernel_d":"","caffe":true,"dilation_h":1,"kernel_regularizer":"None","kernel_h":3},"props":{"name":"l22"}},"l25":{"info":{"phase":null,"type":"Convolution","parameters":2359808},"shape":{"input":[512,14,14],"output":[512,14,14]},"connection":{"input":["l24"],"output":["l26"]},"params":{"layer_type":"2D","stride_d":1,"pad_h":1,"kernel_constraint":"None","activity_regularizer":"None","stride_h":1,"pad_d":0,"weight_filler":"constant","stride_w":1,"dilation_d":1,"use_bias":true,"pad_w":1,"kernel_w":3,"bias_filler":"constant","bias_regularizer":"None","bias_constraint":"None","dilation_w":1,"num_output":512,"kernel_d":"","caffe":true,"dilation_h":1,"kernel_regularizer":"None","kernel_h":3},"props":{"name":"l25"}},"l24":{"info":{"phase":null,"type":"Pooling","parameters":0},"shape":{"input":[512,28,28],"output":[512,14,14]},"connection":{"input":["l23"],"output":["l25"]},"params":{"layer_type":"2D","kernel_w":2,"stride_d":1,"pad_h":0,"stride_h":2,"pad_d":0,"padding":"SAME","stride_w":2,"kernel_d":"","caffe":true,"kernel_h":2,"pad_w":0,"pool":"MAX"},"props":{"name":"l24"}},"l27":{"info":{"phase":null,"type":"Convolution","parameters":2359808},"shape":{"input":[512,14,14],"output":[512,14,14]},"connection":{"input":["l26"],"output":["l28"]},"params":{"layer_type":"2D","stride_d":1,"pad_h":1,"kernel_constraint":"None","activity_regularizer":"None","stride_h":1,"pad_d":0,"weight_filler":"constant","stride_w":1,"dilation_d":1,"use_bias":true,"pad_w":1,"kernel_w":3,"bias_filler":"constant","bias_regularizer":"None","bias_constraint":"None","dilation_w":1,"num_output":512,"kernel_d":"","caffe":true,"dilation_h":1,"kernel_regularizer":"None","kernel_h":3},"props":{"name":"l27"}},"l26":{"info":{"phase":null,"type":"ReLU","parameters":0},"shape":{"input":[512,14,14],"output":[512,14,14]},"connection":{"input":["l25"],"output":["l27"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l26"}},"l29":{"info":{"phase":null,"type":"Convolution","parameters":2359808},"shape":{"input":[512,14,14],"output":[512,14,14]},"connection":{"input":["l28"],"output":["l30"]},"params":{"layer_type":"2D","stride_d":1,"pad_h":1,"kernel_constraint":"None","activity_regularizer":"None","stride_h":1,"pad_d":0,"weight_filler":"constant","stride_w":1,"dilation_d":1,"use_bias":true,"pad_w":1,"kernel_w":3,"bias_filler":"constant","bias_regularizer":"None","bias_constraint":"None","dilation_w":1,"num_output":512,"kernel_d":"","caffe":true,"dilation_h":1,"kernel_regularizer":"None","kernel_h":3},"props":{"name":"l29"}},"l28":{"info":{"phase":null,"type":"ReLU","parameters":0},"shape":{"input":[512,14,14],"output":[512,14,14]},"connection":{"input":["l27"],"output":["l29"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l28"}},"l6":{"info":{"phase":null,"type":"Convolution","parameters":73856},"shape":{"input":[64,112,112],"output":[128,112,112]},"connection":{"input":["l5"],"output":["l7"]},"params":{"layer_type":"2D","stride_d":1,"pad_h":1,"kernel_constraint":"None","activity_regularizer":"None","stride_h":1,"pad_d":0,"weight_filler":"constant","stride_w":1,"dilation_d":1,"use_bias":true,"pad_w":1,"kernel_w":3,"bias_filler":"constant","bias_regularizer":"None","bias_constraint":"None","dilation_w":1,"num_output":128,"kernel_d":"","caffe":true,"dilation_h":1,"kernel_regularizer":"None","kernel_h":3},"props":{"name":"l6"}},"l7":{"info":{"phase":null,"type":"ReLU","parameters":0},"shape":{"input":[128,112,112],"output":[128,112,112]},"connection":{"input":["l6"],"output":["l8"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l7"}},"l4":{"info":{"phase":null,"type":"ReLU","parameters":0},"shape":{"input":[64,224,224],"output":[64,224,224]},"connection":{"input":["l3"],"output":["l5"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l4"}},"l5":{"info":{"phase":null,"type":"Pooling","parameters":0},"shape":{"input":[64,224,224],"output":[64,112,112]},"connection":{"input":["l4"],"output":["l6"]},"params":{"layer_type":"2D","kernel_w":2,"stride_d":1,"pad_h":0,"stride_h":2,"pad_d":0,"padding":"SAME","stride_w":2,"kernel_d":"","caffe":true,"kernel_h":2,"pad_w":0,"pool":"MAX"},"props":{"name":"l5"}},"l2":{"info":{"phase":null,"type":"ReLU","parameters":0,"class":""},"shape":{"input":[64,224,224],"output":[64,224,224]},"connection":{"input":["l1"],"output":["l3"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l2"}},"l3":{"info":{"phase":null,"type":"Convolution","parameters":36928},"shape":{"input":[64,224,224],"output":[64,224,224]},"connection":{"input":["l2"],"output":["l4"]},"params":{"layer_type":"2D","stride_d":1,"pad_h":1,"kernel_constraint":"None","activity_regularizer":"None","stride_h":1,"pad_d":0,"weight_filler":"constant","stride_w":1,"dilation_d":1,"use_bias":true,"pad_w":1,"kernel_w":3,"bias_filler":"constant","bias_regularizer":"None","bias_constraint":"None","dilation_w":1,"num_output":64,"kernel_d":"","caffe":true,"dilation_h":1,"kernel_regularizer":"None","kernel_h":3},"props":{"name":"l3"}},"l0":{"info":{"phase":null,"type":"Input","parameters":0,"class":"hover"},"shape":{"input":[],"output":[3,224,224]},"connection":{"input":[],"output":["l1"]},"params":{"dim":"10, 3, 224, 224","caffe":true},"props":{"name":"l0"}},"l1":{"info":{"phase":null,"type":"Convolution","parameters":1792,"class":""},"shape":{"input":[3,224,224],"output":[64,224,224]},"connection":{"input":["l0"],"output":["l2"]},"params":{"layer_type":"2D","stride_d":1,"pad_h":1,"kernel_constraint":"None","activity_regularizer":"None","stride_h":1,"pad_d":0,"weight_filler":"constant","stride_w":1,"dilation_d":1,"use_bias":true,"pad_w":1,"kernel_w":3,"bias_filler":"constant","bias_regularizer":"None","bias_constraint":"None","dilation_w":1,"num_output":64,"kernel_d":"","caffe":true,"dilation_h":1,"kernel_regularizer":"None","kernel_h":3},"props":{"name":"l1"}},"l8":{"info":{"phase":null,"type":"Convolution","parameters":147584},"shape":{"input":[128,112,112],"output":[128,112,112]},"connection":{"input":["l7"],"output":["l9"]},"params":{"layer_type":"2D","stride_d":1,"pad_h":1,"kernel_constraint":"None","activity_regularizer":"None","stride_h":1,"pad_d":0,"weight_filler":"constant","stride_w":1,"dilation_d":1,"use_bias":true,"pad_w":1,"kernel_w":3,"bias_filler":"constant","bias_regularizer":"None","bias_constraint":"None","dilation_w":1,"num_output":128,"kernel_d":"","caffe":true,"dilation_h":1,"kernel_regularizer":"None","kernel_h":3},"props":{"name":"l8"}},"l9":{"info":{"phase":null,"type":"ReLU","parameters":0},"shape":{"input":[128,112,112],"output":[128,112,112]},"connection":{"input":["l8"],"output":["l10"]},"params":{"negative_slope":0,"caffe":true,"inplace":true},"props":{"name":"l9"}}}' net_name = "Sample Net" reply_channel = "TestChannel" task = export_caffe_prototxt.delay(net, net_name, reply_channel) client = Client() response = client.send('websocket.receive', content=task) # self.assertEqual(response, 'SUCCESS') This is my attempt at writing test for the above function. I know it's not correct and I can't figure out how do I read the message value and then match it. -
how to fill xfa forms using API or coding?
I have a xfa form which I want to fill using API or coding. currently I'm using python (Django). is there any way to fill form using javascript or python ? I'm new to xfa form and googled for a solution but nothing fruitful came. -
BootStrap DashBoard and Django
I'm using the dashboard bootstrap of the link: BootStrapDashBoard for building my page and I already have a page with the listing of items done in Django with Html plus Python and it is working perfectly. So what I did was copy the code from the working table and paste it over the code of the bootstrap table, it shows the table header with the name of each one, but does not list all the items registered. I do not know what I did wrong. remembering that on the page that I copied this code it works perfectly and lists all the items <div class="table-responsive"> <table class="table table-bordered sortable""> <thead class="thead-dark"> <tr> <th scope="col">Id</th> <th scope="col">Nome</th> <th scope="col">Endereço</th> <th scope="col">Telefone</th> </tr> </thead> <tbody> {% for pessoa in pessoas %} <tr> <th scope="row" >{{pessoa.id}}</th> <td > <a href="{% url 'core_pessoa_update' pessoa.id %}" style="color:black">{{pessoa.nome}} </a></td> <td><a href="{% url 'core_pessoa_update' pessoa.id %}" style="color:black">{{pessoa.endereco}}</a></td> <td><a href="{% url 'core_pessoa_update' pessoa.id %}" style="color:black">{{pessoa.telefone}}</a></td> </tr> {% endfor %} </tbody> </table> -
Clearsessions command in Django
Can I run this command on my production server without any risk? Will all sessions be deleted or how is clearsessions affecting my database? -
Serialize two querysets with DjangoRestFramework
I'm trying to serialize more than one queryset, but I noticed that only one of them becomes serialized. This is the approach I'm currently trying. class GetDetails(APIView): def get(self, request): todays_date = time.strftime('%Y-%m-%d') #Get results according to specified criteria queryset = People.objects.filter(date = todays_date, assigned_to = 1) #Check if any querysets are available if queryset: #Iterate through each queryset, serialize and return a response for person in queryset: serializer=ASerializer(queryset) return Response(serializer.data) else: return Response({'TODO':'TODO'}) -
Django/Postgres: in a query with a conditional annotation, return an ArrayField with a certain value in it?
I am using Python 2.7, Postgres 9.6 and Django 1.11. I have a model, Person, with two CharFields on it, director_id and company_id. I'd like to annotate it according to a certain condition: when director_id is not null, do a subquery performing an ArrayAgg that gives me back an array of the company_ids associated with it (fine, got that working); when it is not I'd like to return an array of length 1 simply containing the company_id for this Person. Is there a way to specify that I want default to give back an array with a certain value in it? Person.objects.annotate( aggregated_company_ids=Case( When(director_id__isnull=False, then=Subquery(aggregated_company_ids)), default=[F("company_id")], # ProgrammingError: can't adapt type 'F' output_field=ArrayField(models.CharField()), ), ) -
Is it possible to recover overwritten files from Android Studio?
For a mistake i've overwritten my two project that has same names from android studio and i've dismissed that action today i've tryed to open the main project and i've found no Java classes in it and just the layout's files. While in the second project to which i was overwritting there is a huge confusion of files and trying to recover the project version by using history of Android Studio even those files has disappeared. Is it possible in anyway to recover the whole project? Ps: all that remain from that project is a generated apk.