Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Reliably get client IP for HTTPS request in django?
Is there a way to reliably get client's IP in Django if the request is via HTTPS? For instance, is the data available in request.META['HTTP_X_REAL_IP'] secure against spoofing and other attacks? In my case request.META['REMOTE_ADDR']=='10.0.0.132' which is an internal IP. So I could rely on request.META['HTTP_X_REAL_IP'] or request.META['HTTP_X_FORWARDED_FOR'] only. My site is on pythonanywhere.com, if that matters. So, is there a reliable client IP in request.META via HTTPS? -
Foreign key to different model field in django
I have two models and I want to get- some fields of model 1 to model 2.For that I am using field in model 2 = models.ForeignKey(model1, to_field = 'field i want from model 1') The error which I get in console is myapp.IFileTable.calendar_year: (fields.E304) Reverse accessor for 'IFileTable.calendar_year' clashes with reverse accessor for 'IFileTable.created_on'. HINT: Add or change a related_name argument to the definition for 'IFileTable.calendar_year' or 'IFileTable.created_on'. lfcalendar.IFileTable.title: (fields.E311) 'IFile.title' must set unique=True because it is referenced by a foreign key. My model 1 class IFile(models.Model): title = models.CharField(max_length=255, blank=True) year = models.CharField(max_length=4) uploaded_at = models.DateTimeField(auto_now_add=True) My model 2 class IFileTable(models.Model): title = models.ForeignKey(IntermediateFile, to_field = 'title') user = models.CharField(max_length = 10) created_on = models.ForeignKey(IntermediateFile, to_field = 'uploaded_at') calendar_year = models.ForeignKey(IntermediateFile, to_field = 'year') -
How to create a MultipleInputWidget for the Django ArrayField?
I am used to the Kinto Admin ArrayField selector and I wanted to use a similar interface in the Django Admin. I created a model using an ArrayField: class Article(models.Model): primary_tags = ArrayField( models.CharField(max_length=30) ) Do you know of any AdminWidget that I could use to achieve that? -
LDAP E-Mail Backend in Django
I am working on my webapp by using the Django-Framework. Currently I can login as an LDAP user with the username (using python-auth-ldap). Is there a backend for an LDAP e-mail authentication. I did create a backend for local users (ModelBackend) to login with their e-mail. It workes perfectly fine. But when I try it with LDAP users, this is the error. search_s('DC=sbvg,DC=ch', 2, '(sAMAccountName=%(user)s)') returned 0 objects: Authentication failed for user@domain.com: failed to map the username to a DN. If you have a working backend or any idea, do not hesitate to post it. Thanks in advance. -
Django templates - Image from media_root rendered in homepage, but not other pages
I have an image that renders on my homepage, but it doesn't on a different page using the same code. I figure the problem may be the difference my url path maybe? It's the only difference I can find. When I inspect each element, this is what I see: Working image: /event/image.png Broken Image: /event/media/image.png I'm rendering the image like this in my template: <img src="media/{{event.image}}" class="img-responsive" /> My model is just aa model.Image field and here are is my view for the Broken image page: def event(request, product_id): event = get_object_or_404(Event, id=product_id) image = event.image context = {'event':event, 'image':image} template = 'tourney.html' return render(request, template, context) In my terminal, it says image not found. So how can I change my settings so that it looks in the right directory no matter which path I'm in? Here are my media settings: if DEBUG: MEDIA_URL = '/media/' STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static', 'static-only') MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), 'static', 'media') STATICFILES_DIRS = ( os.path.join(os.path.dirname(BASE_DIR), 'static', 'static'), ) -
Django ArrayField. How to save nested array of time through django admin?
I already asked this question several months ago. Question is stupid, but i cant find solution. What a valid format for saving nested array of time from simple form text field? I have ArrayField like this: schedule = ArrayField( ArrayField( ArrayField( models.TimeField(null=True), ), size=2, null=True, ), size=7, null=True, blank=True, ) When i am trying to save it from django admin like: ((09:00, 09:00), (09:00, 09:00), (09:00, 09:00), (09:00, 09:00), (09:00, 9:00), (9:00, 9:00), (9:00, 9:00)) I'm getting errors Item 0 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time. Item 1 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time. Item 2 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time. Item 3 in the array did not validate: Item 0 in the array did not validate: Item 0 in the array did not validate: Enter a valid time. Item 4 in the array did not validate: Item 0 … -
Django Ceilometer get events for all projects
I have a problem for getting all events for all tenants/projects in Ceilometer. When I get the event list I always get only the list of events related to project that my user assigned. The user is admin in openstack. Explaining in more detail: Here is my sample code: def sync_resources(): logger.info("Executing sync_resources") sync_tenants() tenants = Tenant.objects.all() managers = Manager.objects.filter(is_active=True) for manager in managers: services = manager.services.all() regions = manager.region_set.all() for region in regions: ceilometer_driver = CeilometerDriver(region_name=region.name, **manager.ceilometer_params) if ceilometer_driver.is_authenticated: for tenant in tenants: queries = [ceilometer_driver.make_query("project_id", ceilometer_driver.EQUAL, tenant.tenant_id)] resource_list = ceilometer_driver.get_event_list(query=queries) The sample function uses a driver that I have written. And the driver first authenticates with username,password and project_id. After that it should get the list of events based on prjojects. The problem here is that even the user is admin I can only get the events that the admin is assigned as user. For example instead of getting the events when I try to get the resource list I get all. However when I try events I get only events of projects for the user. # returns all the resources for all tenants/projects resource_list = ceilometer_driver.get_resource_list() # returns only the events for user projects resource_list = ceilometer_driver.get_event_list() … -
Pycharm produces different results if debugging with breakpoints
I'm using pycharm to debug the django development server for analysing a form instantiation where I'm using forms class inheritance. If I run my application without stepping into any breakpoints (temporarily disabling all) then everything works as it should. If I do stop at some breakpoint then the instantiated form produces different results. In particular I have two multiple choices fields, and sometimes only one or both are not bound to the initial value. I can see from the debugger that the part of the code that set field['field_name'].initial = value is executed, nonetheless randomly I get field['field_name'].initial == None. My watches panel is empty so there is no risk that I did modify any values by accident. This is very weird for me! Why would a code execution change depending if I step or not into some breakpoints? What might cause this odd behaviour? -
Django : Validator doens't work when specifying the field to show on the template
i'm new to Django, and i'm working on validators, so i've created a simple form that contains One CharField. after that i wrote a validation method for that field, and everything worked perfectly. form method="POST" action="/veentes">{% csrf_token %} {{form.as_p}} <input type="submit" name="submit"> </form> But when i want to specify the form field that i want to show like: {{form.url}} the form shows but , the validation method doesn't work any more ! here is my form.py: class SubmitUrlForm(forms.Form): url=forms.CharField(label='Submit Form', validators=[validate_url]) validators.py def validate_url(value): url_validator=URLValidator() try: url_validator(value) except: raise ValidationError("Invalid URl !") view : class HomeViews(TemplateView): def get(self, request,*args,**kwargs): form=SubmitUrlForm() context={"title":"submit","form":form} return render(request,"appOne/testPage.html", context) def post(self,request,*args,**kwargs): form=SubmitUrlForm(request.POST) if form.is_valid(): print(form.cleaned_data) context={"form":form} return render(request,"appOne/testPage.html",context) any help please , Thank You. -
How send POST request from localhost (http) to django (https)?
Send to proxy /api with all params (header/cookie/post) as docs PrtScreen with request param (header/cookie/post) And get PrtScreen with response 403 Forbidden server.js 'use strict'; const fs = require('fs'), proxy = require('http-proxy-middleware'), browserSync = require('browser-sync').create(); function returnIndexPageFn(req, res, next) { res.writeHead(200, {'Content-Type': 'text/html'}); res.write(fs.readFileSync('./public/app.html')); res.end(); next(); } browserSync.init({ port: 88, server: { baseDir: 'public/', index: 'app.html', middleware: [ {route: '/home', handle: returnIndexPageFn}, proxy(['/api', '/media'], { target: 'https://security-site.com', logLevel: 'debug', changeOrigin: true, headers: { Referer: 'https://security-site.com', }, }) ] } }); I try another with angular 5, but have the same result((( proxy.conf.json { "/api": { "target": "http://stage.attacher.co/", "secure": false, "changeOrigin": true, "logLevel": "info" } } How to solve this problem? -
Is it possible to run the pyomo solver in Django the framework?
I am setting up a Website for Solving Optimisation Problems on a website. I already built a model and it works. No I need to implement it into the Django framework. Is there any way to pass the Pyomo command as a function, so that the solver runs in a button click? I also ask myself if the framework has enough power to solve such problems. I would gladly appreciate any suggestions as I am also new to web development. -
MultiValue Dict Key Error Django - Forms when trying to display DateField
I have a form with DateField - 'receivedon' attribute as below: forms.py: class PreDataForm(forms.ModelForm): journalname=forms.ChoiceField(required=True,choices=JOURNAL_CHOICES) articletype = forms.ChoiceField(required=True, choices=ARTICLE_TYPES) granttype = forms.ChoiceField(required=True, choices=GRANTS) receivedon=forms.DateField(widget=forms.SelectDateWidget) class Meta: model=PreData fields=['journalname','articlename','articlenumber','caname','camail','articletype', 'country','affliation','granttype','status','receivedon'] I will be asking users to fill that date in html, normal procedure: html: <div class="center col-md-6"> Received On: {{ form.receivedon }} </div> Now i want to upload the date through django views like this: views.py: if request.method=="POST": form=PreDataForm(request.POST or None) print request.POST['receivedon'] if form.is_valid(): instance=form.save(commit=False) instance.save() One thing is that form is always invalid for post request, when i check is_valid function, other thing when I try to display datefield data using request.POST['receivedon'] i am getting Multi Value Dict Key Error Can any one help me with this? Thanks. -
Heroku app crash after deploy (using python with django)
I can't made any change in heroku app like if i am change any single word like HTML. When changes done in git the next step is deploy an app in heroku. When deploy is done the app is crashed. i didn't find any error for this. Please tell me why my app is crashed again and again. Thanks in advance. -
Django-allauth--overriding a view and saving form information
I'm overriding allauth's SignupView in order to add another form into the same view. The other form has additional information that I intend to make mandatory at sign up. But because it's connected to a separate model, Profile, I cannot simply add fields into the original SignupView form. I've managed to render my form into the view, but the input from the additional form will not save. How can I get the secondary form to save? Here's the view: from allauth.account.views import SignupView from .forms import initialPreferenceForm class MySignupView(SignupView): initial_preference_form = initialPreferenceForm def get_context_data(self, *args, **kwargs): # Pass the extra form to this view's context context = super( MySignupView, self).get_context_data(*args, **kwargs) context['initial_preference_form'] = initialPreferenceForm return context def form_valid(self, form): self.user = form.save(self.request) My form: class initialPreferenceForm(forms.ModelForm): class Meta: model = Profile fields = ['favorite1', 'favorite2'] Template: <form class="signup" id="signup_form" method="post" action="{% url 'account_signup' %}"> {% csrf_token %} {{ form|crispy }} {{ initial_preference_form }} {% if redirect_field_value %} <input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" /> {% endif %} <button class="btn btn-primary" type="submit">{% trans "Sign Up" %} &raquo;</button> </form> I'm obtaining the save logic for SignupView from the allauth code: https://github.com/pennersr/django-allauth/blob/master/allauth/account/views.py#L227 -
Photo in my django database wont display
I am trying to display some images from my django database Here are the models class Problemspage(models.Model): problemname = models.CharField(max_length=1000) difficultyproblem = models.CharField(max_length=50) difficultysolution = models.CharField(max_length=50) code = PythonCodeField(blank=True, null=True) photo = models.ImageField(upload_to='static/images', default='static/images') and here are my views where I am using the Id of the problemname to call the name of the problem, e.g 'multiples of 3 and 5' def viewproblem(request, problemnameId): context = { 'title':'Problem ' + problemnameId, 'data': allproblems, 'name': Problemspage.objects.filter(id=problemnameId) } return TemplateResponse(request, 'app/viewproblem.html', context) In my div I am trying to call that image {% for nameofproblem in name %} <img src="{{ nameofproblem.photo.url }}"/> {% endfor %} However I am getting an error Failed to load resource: the server responded with a status of 404 (Not Found) Even though the name of my images and the database are exactly the same. I have checked by copying and pasting the names so that they're identical. Other questions related to this on stackoverflow have not been successful as <img src="{{ nameofproblem.photo.url }}"/> should have worked. It works fine if I call the image directly through static like this: <img src="{% static 'images/Multiples_of_3_and_5.png' %}"/> Note: the underscores don't matter, I have tried making everything with underscores (including … -
Reporting system in Python for multiplatform usage
I am facing a new challenge to write Reporting system. The system will be running on multiple server based on platforms linux and windows. There is actually running JasperReport on those servers but because of the price and other reasons they would like to build their own solution. I am thinking what technologies to use. I know I want to build it within a Python. Base Requirements: wsgi application multiplatform solution (linux/windows servers) possibility to create new reports (this will be done just by me or another programmer. New report=SQL query with the parametr). So once new report will be created on central server must be pushed to all servers. REST API My fist thought was to use Python/Django as that is my favourite couple. The main reason to not use Django I am thinking of, is that I will not use the most of django components: ORM -> no need here because report=SQL query (most of them are already written in actual solution) Authentification must be written custom as there is already database with some user/role logic. No admin needed. I am thinking about to use some microframework such as Flask or so. Please do you have any experience … -
Django ckeditor pdf files upload
I am using django-ckeditor==5.3.1 and django==1.11.2. I need to upload non-image file. I need to pdf files upload. But I can't not find solution for this (for example pdf icon in editor panel). Please hint where I can find this. My model: from ckeditor_uploader.fields import RichTextUploadingField class Event(models.Model): title = models.CharField(max_length=500) date = models.DateField() text = RichTextUploadingField() urls.py urlpatterns += [ url(r'^admin/', include(admin.site.urls)), url(r'^ckeditor/', include('ckeditor_uploader.urls')), ] settings.py CKEDITOR_JQUERY_URL = 'https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js' CKEDITOR_UPLOAD_PATH = 'uploads/' CKEDITOR_ALLOW_NONIMAGE_FILES = True CKEDITOR_CONFIGS = { 'default': { 'toolbar': 'Simple', 'toolbar_Simple': [ ['Bold', 'Italic', 'Underline'], ['Link', 'Unlink'], ['Image', 'Update', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'uploadwidget'], ], 'autoParagraph': False, 'shiftEnterMode': 2, 'enterMode': 2, }, } -
django returning blank page
i'm not sure what is wrong with the code, forms.py from django.form import datetime, widgets import datetime import calendar from bootstrap_datepicker.widgets import Datepicker class DateForm(forms.Form): date_1=forms.DateTimeField(widget=DatePicker( options={"format": "dd/mm/yyyy", "autoclose": True } (help_text ='please enter a date',initial= "year/month/day"))) def cleandate(self): c_date=self.cleaned_data['date_1'] if date < datetime.date.today(): raise ValidationError(_('date entered has passed')) elif date > datetime.date.today(): return date_1 def itamdate(forms.Form): date_check=calendar.setfirstweekday(calendar.SUNDAY) if c_date: if date_1==date_check: pass elif date_1!=date_check: raise ValidationError('The Market will not hold today') for days in list(range(0,32)): for months in list(range(0,13)): for years in list(range(2005,2108)): views.py from django.shortcuts import render, get_object_or_404 from django.http import HttpResponseRedirect from django.urls import reverse import datetime from .forms import DateForm def imarket(request): #CREATES A FORM INSTANCE AND POPULATES USING DATE ENTERED BY THE USER form_class= DateForm form = form_class(request.POST or None) if request.method=='POST': #checks validity of the form if form.is_valid(): return HttpResponseRedirect(reverse('welcome.html')) return render(request, 'welcome.html', {'form':form}) welcome.html ** {% extends 'base.html' %} {% block content %} <title>welcome</title> <form action = "{% url "imarket"}" method = "POST"> {% csrf_token %} <table> {{form}} </table> <input type ="submit" value= "CHECK"/> </form> {% endblock %} ** i am trying to implement a datepicker on the welcome page, i have called the form in the views.py , and returned the "welcome.html" … -
demo application issue with models and queryset
I am trying to make one simple application but seems like facing issue. I have created many to many object between student and course and has also define dept. My model is mentioned below: class Course(models.Model): courseId = models.AutoField(primary_key=True) courseName = models.CharField(max_length=100) enrolledStu = models.IntegerField(max_length=3) students = models.ManyToManyField(Student) dept = models.ForeignKey(Dept, on_delete=models.CASCADE) def __str__(self): return '%s %s %s %s' % (self.courseName,self.enrolledStu,self.students,self.dept) class Dept(models.Model): deptId = models.AutoField(primary_key=True) deptName = models.CharField(max_length=100) def __str__(self): return '%s %s' % (self.deptId, self.deptName) class Student(models.Model): stuName = models.CharField(max_length=100) stuCity = models.CharField(max_length=100) stuPhone = models.IntegerField(max_length=10) stuNationality = models.CharField(max_length=50) stuCreatedt = models.DateTimeField(default=timezone.now) def __str__(self): return '%s %s %s' % (self.stuName,self.stuCity,self.stuNationality) my form is : class StudentForm(forms.ModelForm): class Meta: model = Student fields = ('stuName','stuCity','stuPhone','stuNationality','stuCreatedt') class CourseForm(forms.ModelForm): class Meta: model = Course fields = ('courseId','courseName','enrolledStu','students','dept') class DeptForm(forms.ModelForm): class Meta: model = Dept fields = ('deptId','deptName') I have displayed list of course , students and dept in html template now i am trying to edit it with code : def edtStudent(request,pk): course = Course.objects.filter(pk=1).prefetch_related('students').select_related('dept').get() if request.method =="POST": form = CourseForm(request.POST,instance=Course) if form.is_valid(): course = form.save(commit=False) print(form.cleaned_data) course.courseName = request.POST['courseName'] course.enrolledStu = request.Post['enrolledStu'] course.save() course.save_m2m() return redirect('liststudent') else: print(course.__dict__) print(course.students) #form = CourseForm() #return render(request, 'stuApp/edtStudent.html', {'form':form}) #form = CourseForm(instance=course[0]) worked … -
Django IntegrityError NOT NULL constraint failed: accounts_solution.puzzle_id
So I am creating a puzzling app, where you can submit Solutions to puzzles, and add Comments to Solutions. Here are my models: class Solution(models.Model): user = models.ForeignKey( User, on_delete=models.CASCADE, ) puzzle = models.ForeignKey( Puzzle, on_delete=models.CASCADE, ) title = models.CharField(max_length=30) content = models.TextField() points = models.IntegerField() datetime = models.DateTimeField(default=timezone.now, blank=True) def __str__(self): return self.title class Comment(models.Model): user = models.ForeignKey( User, on_delete=models.CASCADE, ) solution = models.ForeignKey( Solution, on_delete=models.CASCADE, ) title = models.CharField(max_length=30) content = models.TextField() datetime = models.DateTimeField(default=timezone.now, blank=True) def __str__(self): return self.title I am trying to implement an Add Comment feature using standard Django Forms. Here is my views: if request.method == "POST": # Add Comment feature form = AddCommentForm(request.POST) if form.is_valid(): comment = form.save(commit=False) comment.user = request.user comment.solution = Solution.objects.get(id=solutionID) ## Debugging ## print(comment.title) print(comment.content) print('Solution:') print(comment.solution) print('Puzzle: ') print(comment.solution.puzzle) print(comment.solution.puzzle.id) ############### comment.save() messages.success(request, 'Solution was created successfully!') return HttpResponseRedirect(reverse("solutions", kwargs={'puzzleID': puzzleID})) else: messages.warning(request, 'There are some errors on the form.') return render(request, "add_solution.html", { "form": form, }) And of course my forms: class AddCommentForm(forms.ModelForm): def __init__(self, *args, **kwargs): super(AddCommentForm, self).__init__(*args, **kwargs) self.fields['title'].widget.attrs['placeholder'] = 'Title' self.fields['content'].widget.attrs['placeholder'] = 'Content' title = forms.CharField() content = forms.CharField( widget=forms.Textarea(attrs={ "rows": 6, }), ) class Meta: model = Solution fields = ['title', 'content'] When … -
self.alias2op: typing.Dict[str, SQLToken] = alias2o
I am trying to integrate mongoDB with django using djongo package, when I do python3 manage.py migrate am getting the following error.. Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/home/eindhan/.local/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line utility.execute() File "/home/eindhan/.local/lib/python3.5/site-packages/django/core/management/__init__.py", line 347, in execute django.setup() File "/home/eindhan/.local/lib/python3.5/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/eindhan/.local/lib/python3.5/site-packages/django/apps/registry.py", line 112, in populate app_config.import_models() File "/home/eindhan/.local/lib/python3.5/site-packages/django/apps/config.py", line 198, in import_models self.models_module = import_module(models_module_name) File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 673, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 665, in exec_module File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "/home/eindhan/.local/lib/python3.5/site-packages/django/contrib/auth/models.py", line 2, in <module> from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "/home/eindhan/.local/lib/python3.5/site-packages/django/contrib/auth/base_user.py", line 47, in <module> class AbstractBaseUser(models.Model): File "/home/eindhan/.local/lib/python3.5/site-packages/django/db/models/base.py", line 114, in __new__ new_class.add_to_class('_meta', Options(meta, app_label)) File "/home/eindhan/.local/lib/python3.5/site-packages/django/db/models/base.py", line 315, in add_to_class value.contribute_to_class(cls, name) File "/home/eindhan/.local/lib/python3.5/site-packages/django/db/models/options.py", line 205, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "/home/eindhan/.local/lib/python3.5/site-packages/django/db/__init__.py", line 33, in __getattr__ return getattr(connections[DEFAULT_DB_ALIAS], item) File "/home/eindhan/.local/lib/python3.5/site-packages/django/db/utils.py", line 202, in __getitem__ backend = load_backend(db['ENGINE']) File "/home/eindhan/.local/lib/python3.5/site-packages/django/db/utils.py", line 110, in load_backend return import_module('%s.base' % backend_name) File "/usr/lib/python3.5/importlib/__init__.py", line … -
google oauth2client error no attibute sign
Trying to add google analytics report on my project in python. It shows error Exception Value: 'str' object has no attribute 'sign' I install PyOpenSSL but problem isnt solved. Using python 3.6, Django 2.0.3, oauth2client==4.1.2, pyOpenSSL==17.5.0 -
Serving static files during development without relying on django.contrib.staticfiles
I'm trying to keep my front and back ends completely separate. Front end is a template developed in node-land with (I hope) minimal or no context involvement, back-end is a set of TemplateViews and an API. I'm building my frontend to my frontend directory, so that's easy enough, I just set in settings.py: TEMPLATES = [ { "DIRS": ["frontend/"] ... I'm running into difficulties when these templates reference assets like: <link rel="assets/css/foobar.css" /> foobar.css is present at the relevant location, but the dev server doesn't know to look there. Obviously in production the proxy server will be serving these files directly, but can I get the django dev server to do that while I'm developing? I really want to avoid prefixing with {{ STATIC_URL }} and other template tags that couple the back end to the templates. -
Index not showing in Kibana 6.2
So I'm using Elasticsearch and Kibana to show specific user events that my Django App sends with elastic-py. I was using the 5.5 version before and it worked great, but for different reasons, I had to change the server itself and decided to use this opportunity to upgrade to ELK 6.x. So I set up a new fresh install of Elasticsearch and Kibana 6.2.2 in another server with the X-Pack also and did a few tweaks to my old code: Before . . . 'mappings': { 'example_local': { 'properties': { 'action': {'index': 'not_analyzed', 'type': 'string'}, 'date': {'index': 'not_analyzed', 'format': 'dd-MM-yyyy HH:mm:ss', 'type': 'date'}, 'user_type': {'index': 'not_analyzed', 'type': 'string'}, . . . After . . . 'mappings': { 'example_local': { 'properties': { 'action': {'type': 'text'}, 'date': {'format': 'dd-MM-yyyy HH:mm:ss', 'type': 'date'}, 'user_type': {'type': 'text'}, . . . After that, I added the user and password to my connection, one thing that in my old ELK couldn't do. host_port = '{}:{}'.format(settings.ELASTICSEARCH['host'], settings.ELASTICSEARCH['port']) Elasticsearch(host_port, http_auth=(settings.ELASTICSEARCH['username'],settings.ELASTICSEARCH['password'])) And at last, I created my index and went running to Kibana to see how my last 4 hours of struggle finally paid off. But in the Management -> Kibana -> Index Patterns there was only 1 index, … -
SQL database. I dropped a table, how can i now create it?
To drop table i used that commands : python manage.py dbshell .tables DROP TABLE table_what_i_drop; after i tried : python manage.py makemigrations and python manage.py migrate but table wasn't created. I deleted migrations folders from all apps and dbsqlite3 file and tried again makemigrations and migrate, but databases wasn't created. Now when i tried python manage.py dbshell .tables there is no tables for any of my app. I know that loosing tables is my fault, but how i can make all databases from the beginning ?