Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django rest framework for external views?
Is it possible to create Django web service which will be served for external views? Just hit that service and fetch the values. The most of the examples i found are with django web application views and templates. -
Django project set up with Apache2 - i want to access it through I.P/application_name/
Hi I want to set up my django project to be access through apache2 by I.P/application_name/ So "192.0.0.0/app/" (Ip being an example) Here is my 000-default.conf file in etc/apache2/sites-available <VirtualHost *:80> ServerName www.example.com ServerAlias example.com ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined WSGIDaemonProcess HTSv2 python-home=/home/django/config/env python-path=/usr/local/django/app WSGIProcessGroup HTSv2 WSGIScriptAlias / /usr/local/django/app/application/wsgi.py <Directory /usr/local/django/app/application> <Files wsgi.py> Require all granted </Files> </Directory> Alias /static/ /usr/local/django/app/static/ <Directory /usr/local/django/app/static> Require all granted </Directory> <Directory /usr/local/django/app> Deny from all Allow from ... </Directory> </VirtualHost> When I change the line: WSGIScriptAlias / /usr/local/django/app/application/wsgi.py to WSGIScriptAlias /app/ /usr/local/django/app/application/wsgi.py I can access the home page of my application by 192.0.0.0/app/ However when I click on any buttons, obviously does not keep to this, so for example going to page1, does not go to 192.0.0.0/app/page1, it goes to 192.0.0.0/page1 How can I configure apache2 to do this? The reason I want to do this is so I can host multiple projects on the same server, so the root of 1 project is 192.0.0.0/app1/ and then the root of the other is 192.0.0.0/app2/ etc... -
FOREIGN KEY constraint failed using get_or_create
Traceback: http://dpaste.com/126CW8T The view that triggers the error is this: @login_required() def add_to_cart(request, **kwargs): user_profile = get_object_or_404(UserProfile, user=request.user) user_order, status = Order.objects.get_or_create(owner=user_profile) Model: class Order(models.Model): fecha_reparto = models.ForeignKey(DiasDeReparto, on_delete=models.CASCADE, default= 1) order_nodo = models.ForeignKey(Nodo, on_delete=models.CASCADE, default= 1) ref_code = models.CharField(max_length=15) owner = models.ForeignKey(UserProfile, on_delete=models.CASCADE) is_ordered = models.BooleanField(default=False) date_ordered = models.DateTimeField(null=True) -
paragraph tags not breaking lines (django, ckeditor)
A user of our site is having trouble preserving the formatting of their story. They're using a ckeditor field to upload the story. Here's the raw input: <p style="margin-left:0in; margin-right:0in"><span style="color:#191c1f">I asked him what his tattoo meant. It was a cartoon mouse with a bandit mask. </span></p> <p style="margin-left:0in; margin-right:0in">&nbsp;</p> <p style="margin-left:0in; margin-right:0in"><span style="color:#191c1f">He&rsquo;s meant to be me, he said.</span></p> <p style="margin-left:0in; margin-right:0in">&nbsp;</p> <p style="margin-left:0in; margin-right:0in"><span style="color:#191c1f">* * *</span></p> <p style="margin-left:0in; margin-right:0in">&nbsp;</p> <p style="margin-left:0in; margin-right:0in"><span style="color:#191c1f">The first time I slept with someone else, he found out the next day.</span></p> <p style="margin-left:0in; margin-right:0in">&nbsp;</p> <p style="margin-left:0in; margin-right:0in"><span style="color:#191c1f">I didn&rsquo;t know we were exclusive, I said.</span></p> <p style="margin-left:0in; margin-right:0in">&nbsp;</p> <p style="margin-left:0in; margin-right:0in"><span style="color:#191c1f">You didn&rsquo;t know we were exclusive.</span></p> <p style="margin-left:0in; margin-right:0in">&nbsp;</p> <p style="margin-left:0in; margin-right:0in"><span style="color:#191c1f">Yes.</span></p> This is how the input appears: "I asked him what his tattoo meant. It was a cartoon mouse with a bandit mask. He’s meant to be me, he said.* * * The first time I slept with someone else, he found out the next day. I didn’t know we were exclusive, I said. You didn’t know we were exclusive. Yes." The html that is on the web page looks identical to the source html. Whenever I copied the … -
How to inherit Django variables?
I'm having a little trouble wrapping my head around inheritance in Django. Here is an abstracted test case of my problem. (Note that my app is called viz and I've just built this test case under it) urls.py from django.urls import path from viz import views urlpatterns = [ path('test.html', views.test_view, {}, name='test'), path('inherit_from_test.html', views.inherit_from_test_view, {}, name='inherit_test') ] viz/views.py def test_view(request): return render(request, "viz/test.html", context={'hello': 'hello'}) def inherit_from_test_view(request): return render(request, "viz/inherit_from_test.html", context={'django': 'django' }) viz/static/viz/test.html <body> <h1> {{ hello }} </h1> <h2> {% block content %} {% endblock %} </h2> </body> </html> viz/static/viz/inherit_from_test.html {% extends "viz/test.html" %} {% block content %} {{ django }} {% endblock %} As expected, the test.html file has a single h1 tag, which says hello. However I was expecting to see the both the h1 and h2 tag in inherit_from_test.html. Instead the inherit_from_test.html file only contains the h2 tag saying Django. Why has the inherit_from_test.html not inherited the contents of the {{ hello }} variable? -
Dynamically hide a field in django admin?
What I am trying to do is when a Boolean is True is display certain fields and if the Boolean is false, do not display them. To the fields I am trying to hide are TextField and CharField if that has any effect. I have made a solution but it is not ideal. What I have done using the def_fields function in the admin class, is on creation, all the fields will be displayed and then after you save it the fields will display accordingly to what the Boolean is displaying. This is not ideal because I would like to have it dynamically, so when I select this Boolean, it will remove the fields from the view immediately. -
Blog in Django 1.11 Mapping URLs to Views
I'm new to Django (1.11) and Python(2.7). I'm trying to create a blog. I have a problem wih mapping URLs to views. My myblog\posts\views.py: from __future__ import unicode_literals from django.shortcuts import render from django.http import HttpResponse # Create your views here. def post_home(request): return HttpResponse("<h1>Hello</h1") My myblog\myblog\urls.py: from django.conf.urls import url from django.contrib import admin from posts import views urlpatterns = [ url(r'^admin/', admin.site.urls), url(r'^posts/$', posts_view.post_home), ] My myblog\myblog\settings.py: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'posts', ] TypeERROR: view must be a callable or a list/tuple in the case of include() Any help would be greatly appreciated! -
UNIQUE constraint failed: accounts_user.username
Let's get to the problem I have a page where I want users to fill info about themselves, and i would like to save that data. But I'm getting this error. IntegrityError at /accounts/profile/edit/1/change-profile/ UNIQUE constraint failed: accounts_user.username this is my view.py def change_profile(request, pk): form = ChangeProfile(request.POST or None) user_ = request.user if request.method == "POST": if form.is_valid(): form.save() return redirect("/accounts/profile/edit/{}/".format(user_.pk)) args = {'form': form} return render(request, 'change_profile.html', args) my models.py class GradeUser(models.Model): grade = models.CharField(max_length=20, null=True) class Country(models.Model): country = models.CharField(max_length=30, null=True) class User(AbstractBaseUser): email = models.EmailField( verbose_name = 'email address', max_length=255, unique=True ) real_name = models.CharField(max_length=20, blank=True) username = models.CharField(max_length=40, unique=True, verbose_name='username') grade = models.ForeignKey(GradeUser, on_delete=models.CASCADE, blank=True, null=True) country = models.ForeignKey(Country, on_delete=models.CASCADE, blank=True, null=True) reputation = models.IntegerField(default=0) image = models.ImageField(upload_to='accounts/media', blank=True) about_me = models.TextField() USERNAME_FIELD= 'email' REQUIRED_FIELDS = ['username'] objects = UserManager() forms.py class ChangeProfile(forms.ModelForm): class Meta: model = User fields = ('real_name', 'grade', 'country', 'about_me') What does exactly go wrong? Why would it need a user's username? What should I do with it to save? -
Django form not getting validated even if correct?
So I have been trying to implement a way to post a project post that is able to upload multiple images at the same time. Both of my forms are not getting validated even tho they are correct and complete. I am not sure what am I doing wrong. My codes are below: views.py class CreateProjectsView(View): def get(self, request): p_photos = P_Images.objects.all() #project_form = ProjectsForm(initial=self.initial) project_form = ProjectsForm() context = { 'p_photos': p_photos, 'project_form': project_form, } return render(self.request, 'projects/forms.html', context) def post(self, request): project_form = ProjectsForm(request.POST or None, request.FILES or None) multi_img_form = P_ImageForm(request.POST, request.FILES) if project_form.is_valid() and multi_img_form.is_valid(): instance = project_form.save(commit=False) instance.user = request.user instance.save() images = multi_img_form.save(commit=False) images.save() data = { 'is_valid': True, 'name': images.p_file.name, 'url': images.p_file.url } else: data = { 'is_valid': False, } return JsonResponse(data) forms.html {% extends "projects/test.html" %} {% block javascript %} <form action="{% url 'create_post:create_projects' %}" method="POST" enctype="multipart/form-data"> {% csrf_token %} {% for hidden in project_form.hidden_fields %} {{ hidden }} {% endfor %} {% for field in project_form %} {{ field.errors }} {{ field }} <br /> {% endfor %} <input type="submit" value="OK"> {% load static %} {# JQUERY FILE UPLOAD SCRIPTS #} <script src="{% static 'projects/js/jquery-file-upload/vendor/jquery.ui.widget.js' %}"></script> <script src="{% static 'projects/js/jquery-file-upload/jquery.iframe-transport.js' %}"></script> … -
(Django) One UpdateView many forms
I'm working for my training center to develop a web application. I have a page with a list of clients, and would like to be able to click a link to update their profile. When 'update' is clicked, I should be able to edit the username, first name, ... email, phone number, street etc, in a single page, using a single submit button. I accomplished this by using five forms, one for User, one for the extra information, one for the address, one for the zip code and one for the number of the street. The ListView, and CreateView work perfectly with these five forms, but not the UpdateView. I am not able to update the instance and it create a new instance at each submit. The question is: what did I do wrong, please ? Thanks. views.py: class ClientUpdate(UpdateView): model = Client template_name = 'garage/client_update.html' form_class = ZipCodeForm second_form = CityForm third_form = AddressForm fourth_form = DonneesPersonnellesForm fifth_form = ClientForm # success_url = reverse_lazy('garage/clients') def get_context_data(self, **kwargs): client = self.object address = client.adresse zipCode = address.zipCode city = address.city donneesPersonnelles = client.donnees_personnelles_client context = super(ClientUpdate, self).get_context_data(**kwargs) if 'form' not in context: context['form'] = self.form_class(instance=zipCode) if 'form2' not in context: … -
Django rest api filtering error message: django.core.exceptions.FieldError: Related Field got invalid lookup
I am trying to query my database with name contains in the MainName which will filter Profile with this query : Profile.objects.all().filter(simmatch__mainname__mainname=name.lower()) But I am having this error message: django.core.exceptions.FieldError: Related Field got invalid lookup: mainname Can someone tell me what I am doing wrong ? Thanks! My models: class Profile(models.Model): ID = models.IntegerField(unique=True, primary_key=True) name = models.CharField(max_length=200) hasArticle = models.CharField(max_length=3) gender_guessed = models.CharField(max_length=5) age = models.CharField(max_length=5) profile = models.TextField() def __str__(self): return "{}".format(self.name) class MainName(models.Model): ID = models.IntegerField(unique=True, primary_key=True) mainName = models.CharField( max_length=100) #primary_key=True def __str__(self): return "{}".format(self.mainName) class SimMatch(models.Model): profile = models.ForeignKey(Profile,to_field="ID", db_column="profile_ID",on_delete=models.CASCADE,) mainName = models.ForeignKey(MainName, to_field="ID", db_column="ID",on_delete=models.CASCADE,) def __str__(self): return "{}-{}".format(self.mainName,self.profile) My querry: Profile.objects.all().filter(simmatch__mainname__mainname=name.lower()) -
Django: dynamic changing email recepients
I making a feedback form on website. I made model called 'globalapp' with all settings for future admin, it have email,address and phone fields without permissions for add or delete this objects. In my views i have a simple code: def index(request): seos = SEO.objects.get(id__exact=1) socs = Social_networks.objects.get(id__exact=1) globs = globalapp.objects.get(id__exact=1) index = Index.objects.get(id__exact=1) form = ContactForm(request.POST) if form.is_valid(): subject = form.cleaned_data['subject'] sender = form.cleaned_data['sender'] message = form.cleaned_data['message'] fille = form.cleaned_data['fille'] recepients = ['test@test.ru'] from_email, to = sender, recepients html_content = loader.render_to_string('globalapp/chunks/email_tpl.html', {'subject': subject, 'sender':sender, 'message':message, 'fille':fille}) msg = EmailMultiAlternatives(subject, html_content, from_email, to) msg.send() return render(request, 'globalapp/index.html', {'seos': seos, 'socs': socs, 'globs': globs, 'index': index, 'form': form }) Right now mail sending on test@test.ru. I want to take email field from globalapp object, and put it in 'recepients', to give admin ability to change email address when he needs it. The best thing that i get yet, i get email value by queryset with: email = globalapp.objects.filter(id=1).values('email') by in mail ive got only To: {'email': 'test@gmail.com'} So question is how to get string from queryset object for dynamic email recepients changing? Or maybe i have option how to do it other way? Also i have another little problem, that i … -
How to filter data after joining two tables in django
I have joined two table in the serializer and now i want to filter the record based on the department id the department id will be stored in the cache of the browser how to apply filter to the below set i have joined two tables and i want to apply the filter the data to be used in the filter will be stored in cache of the browser. class LevelSerializer(serializers.ModelSerializer): class Meta: model = Level class LevelProcessSerializer(serializers.ModelSerializer): level = LevelSerializer(read_only=True) class Meta: model = LevelProcess Usage in your ModelViewset: class ViewLevelProcessViewSet(viewsets.ModelViewSet): queryset = LevelProcess.objects.all() serializer_class = LevelProcessSerializer -
unable to start python manager.py runserver
I am creating a sample application using Python V3.6 and Django V2.1, previously I have faced an issue related to MySQL client, so I have fixed that by using "pip install "mysqlclient==1.3.12" I help to install the mysqlclient successfully but later on when I tried to run my application I'm getting this following error. Performing system checks... System check identified no issues (0 silenced). Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x0000000003A93C80> Traceback (most recent call last): File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\base\base.py", line 2 16, in ensure_connection self.connect() File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\base\base.py", line 1 94, in connect self.connection = self.get_new_connection(conn_params) File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\django\db\backends\mysql\base.py", line 227, in get_new_connection return Database.connect(**conn_params) File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\MySQLdb\__init__.py", line 86, in Connec t return Connection(*args, **kwargs) File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\MySQLdb\connections.py", line 204, in __ init__ super(Connection, self).__init__(*args, **kwargs2) _mysql_exceptions.OperationalError: (1045, "Access denied for user 'ODBC'@'localhost' (using password: NO)") Extra-detailed tracebacks for bug-reporting purposes can be enabled via: %config Application.verbose_crash=True Error in atexit._run_exitfuncs: Traceback (most recent call last): File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\IPython\core\history.py", line 780, in w riteout_cache self._writeout_input_cache(conn) File "C:\Users\ccduce\AppData\Local\Continuum\miniconda3\lib\site-packages\IPython\core\history.py", line 764, in _ writeout_input_cache (self.session_number,)+line) sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread.The object was crea ted in thread id 1776 and this is thread id 10192 Setting.py … -
relation "django_session" does not exist - django, heroku
I deployed my app on Heroku, I can see it perfectly from the local server where the website works. The problem is that whenever I try to enter as the admin within the Heroku website (https://awayfromspain.herokuapp.com/admin/) I got the following error: ProgrammingError at /admin/ relation "django_session" does not exist LINE 1: ...ession_data", "django_session"."expire_date" FROM "django_se... I also get this when I try to enter in the pages that are related to my models: column myapp_experience.slug does not exist LINE 1: ...p_experience"."title", "myapp_experience"."text", "myapp_exp... I think I have problems with the database... but I tried to flush and I get: Running python manage.py flush on ⬢ awayfromspain... up, run.2445 (Free) You have requested a flush of the database. This will IRREVERSIBLY DESTROY all data currently in the 'df1neimk7ipkd5' database, and return each table to an empty state. Are you sure you want to do this? Type 'yes' to continue, or 'no' to cancel: yes CommandError: Database df1neimk7ipkd5 couldn't be flushed. Possible reasons: * The database isn't running or isn't configured correctly. * At least one of the expected database tables doesn't exist. * The SQL was invalid. Hint: Look at the output of 'django-admin sqlflush'. That's the SQL this command wasn't … -
How to add items to array field in django?
I have a model called Shop.It is defined as below class Shop(models.Model): name = models.CharField(max_length=50) city = models.TextField() items = ArrayField(ArrayField(models.TextField())) Now I want to add multiple items to the items field for the same shop.Currently to add one item to the Shop model, this is how I do it @csrf_exempt def shopping(request): user_request = json.loads(request.body.decode('utf-8')) if request.method == "POST": if user_request.get("action") == "add": conv = Shop.objects.create( name=user_request.get("name"), city=user_request.get("city"), items=user_request.get("itme") ) return HttpResponse(1) But it only stores one item for the particular name.So I need to append more items. How do I append to an arrayfield? -
Django + Memcached: get all entries
I would like to use Memcached and Django. I need to store some entries key-value with an expiration timeout. In this way, using Memcached with expiration timeout, I can clear automatically all expired entries. But I need also to retrieve all current stored entries. Is there a way to get all contained entries in memcached using Django. An example of my idea: We can suppose to store in cache the last users locations. I'm interested to store only the last user locations that I can receive form mobile app (for example) so, I can set a timeout (expiration) when I add a entry in the cache. In this way Memechached will clears automatically all expired entries and I not have to manage manually it. This is ok form me But I need also of a method to get all the actually contained entries (not expired). I'm not found an api to retrieve all current entries using Django + Memcached. Is it possible? -
How to format django DateField in model from YYYY-MM-DD to MM-DD-YYYY
I have an excel file with over 40 thousand lines to import into MYSQL and the date format in the excel file is MM-DD-YYY while the corresponding MYSQL field is expecting YYYY-MM-DD. I used django to create the MYSQL Table with the migration command. -
Django-wkhtmltopdf crashes on server
I have an app using django-wkhtmltopdf. It is working locally, but when I run on a VPS I'm getting the following error. Command '['wkhtmltopdf', '--allow', 'True', '--enable-local-file-access', '--encoding', 'utf8', '--javascript-delay', '2000', '--page-height', '465mm', '--page-width', '297mm', '--quiet', '/tmp/wkhtmltopdffyknjyrk.html', '-']' returned non-zero exit status 1. I'm guessing I need to set some permissions on the VPS to allow the temp file to be created (or set a directory for it) but I'm not sure how to do this. Within settings.py I have WKHTMLTOPDF_CMD_OPTIONS = { 'quiet': True, 'allow' : '/tmp', 'javascript-delay' : 1000, 'enable-local-file-access' : True, } And within the django view I've got: cmd_options = { #'window-status' : 'ready', 'javascript-delay': 2000, 'page-height' : '465mm', 'page-width' : '297mm', 'allow' : True, #'T' : 0, 'R' : 0, 'B' : 0, 'L': 0, } -
django Failed to build mysqlclient
I have created a sample Django application on Window 7 and I'm using Python V3.6 and Django 2.1 for this application we planned to use Mysql database. SO I have tried to install by the command pip install django mysqlclient Failed building wheel for mysqlclient Running setup.py clean for mysqlclient Failed to build mysqlclient Installing collected packages: mysqlclient Running setup.py install for mysqlclient ... error Complete output from command c:\users\ccduce\appdata\local\continuum\miniconda3\python.exe -u -c "import setuptoo ls, tokenize;__file__='C:\\Users\\ccduce\\AppData\\Local\\Temp\\pip-install-dw406d2r\\mysqlclient\\setup.py';f=getatt r(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec' ))" install --record C:\Users\ccduce\AppData\Local\Temp\pip-record-je8ir8xy\install-record.txt --single-version-exter nally-managed --compile: c:\users\ccduce\appdata\local\continuum\miniconda3\lib\distutils\dist.py:261: UserWarning: Unknown distribution o ption: 'long_description_content_type' warnings.warn(msg) running install running build running build_py creating build creating build\lib.win-amd64-3.6 copying _mysql_exceptions.py -> build\lib.win-amd64-3.6 creating build\lib.win-amd64-3.6\MySQLdb copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.6\MySQLdb\constants running build_ext building '_mysql' extension error: [WinError 3] The system cannot find the path specified: 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\PlatformSDK\\lib' ---------------------------------------- Command "c:\users\ccduce\appdata\local\continuum\miniconda3\python.exe -u -c "import setuptools, tokenize;__file__='C :\\Users\\ccduce\\AppData\\Local\\Temp\\pip-install-dw406d2r\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open )(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\ Users\ccduce\AppData\Local\Temp\pip-record-je8ir8xy\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\ccduce\AppData\Local\Temp\pip-install-dw406d2r\mysqlclient\ Setting.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': '*****', … -
Django; Tips for making views thin
I'm a beginner and I have been working on project using Django. I am wondering if there's a good way to avoid repeating the same code. Also if there are similar logic in some functions, how can I decide if the logic is organized or not. for example, def entry_list(request): entry_list = Entry.objects.all() #this part is repeated page = request.GET.get('page', 1) paginator = Paginator(entry_list, 10) try: entries = paginator.page(page) except PageNotAnInteger: entries = paginator.page(1) except EmptyPage: entries = paginator.page(paginator.num_pages) return render(request, 'blog/entry_list.html', {'entries': entries}) The logic to paginate is repeated in some other functions as well. Where should I put the repeated code and how can I decide if I should organize code? -
Formatting Django web app for 1024x768
I am currently formatting my Django web application using twitter bootstrap, but things start getting weird when I resize the browser. Ideally, I would like to keep the same format regardless of browser size, and if they go too small, than just a horizontal scroll is introduced: If the screen resolution is 1024x768, I want the site to look good (using the full width of the screen, no warping or adjustments of image files, no horizontal scroll). If the display is wider than 1024px, there are blank space on either size. If narrower than 1024px, a horizontal scroll is introduced. I was wondering what the best way to go about this is. Is there a way with twitter bootstrap? I was also thinking of putting everything into a boarder less table with defined widths and centering the table on the screen? Hoping then things inside the table wouldn't resize down. -
Is there a way to call Ajax load() method from a Python script in a Django project?
I am running a couple of repeating background tasks asynchronously with the help of django-background-tasks in my Django project, which all last between 1-5 minutes to complete. Each task saves objects into the project's database and the website displays the most recent data from the database tables. Obviously I then wanted to have the page to update the displayed data without the user having to manually refresh every time. I decided to do this with Ajax load() method provided by jQuery since only specific tags are required to be reloaded. However, since it's impossible for me to estimate how long each task takes to complete, I temporarily just placed the ajax load requests inside a javascript setInterval() method that executes every 10 seconds. This is however an unnecessary amount of reloading and therefore I'm wondering if there was a better way I could have the ajax load requests execute only when a background task is completed and new objects are saved to the database. If it helps to enlighten my situation any better, here's what I've got: The project's urls.py file: urlpatterns = [ path('', general.views.GeneralView.as_view(), name='general'), ... path('ajax/status1', alarms1.views.status, name='status1'), path('ajax/status2', alarms2.views.status, name='status2'), ] alarms1.tasks.call_alarms(repeat=10, repeat_until=None) alarms2.tasks.call_alarms(repeat=10, repeat_until=None) #these … -
Aviation Start-up APP
Really new to this but please check my profile out, I'm based in Hertfordshire UK and if you're interested in working with an aviation start-up as a CTO lets chat. -
Django wagtail, error uploading a video to a text block
When I try to upload a video through the built-in textbox functionality, I get an error: Request Method: POST Request URL: http://127.0.0.1:8000/admin/pages/178/edit/ Django Version: 1.11 Exception Type: AttributeError Exception Value: 'function' object has no attribute 'void_element_close_prefix' At the same time, I already have a page with such a video, and when I try to re-publish it gets the same error.