Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
python django: login with office 365
I am trying to implement a office365/azureAD/MS graph authentication system for a Django website. My University has a office365 account system for all students. If you log in using your ID for that you get access to all MS Office software and other university systems. Looks like this: I'm trying to make it so that students can log into my website using this system. Rather than me implementing a user/password model and associated views etc. I feel like I've been going around in circles. I'd appreciate any help. -
Django and Howler.js instances in for loop
I'm trying to iterate over a list of audio objects and create a howler.js object for each instance. Each howler instance should be able to be play, pause, and reset to the beginning. I'm only able to call the play function of each howler instance atm, hoping someone better versed in JS can help me out {% for obj in instance %} <script type="text/javascript"> function play(src){ var sound = new Howl({ src:[src], format: ['wav'], volume: 0.5, }); var play = sound.play(); }; </script> <button type="button" class="btn btn-primary"><a onclick="play('{{obj.sound.url}}')" style="color: white;">Play</a></button> {% endfor %} I've tried several different configurations, but this is the closest I've gotten to what I need. The problem is, I can't call pause/change the object that's created with the onclick event. If I try and call play separately from the Howl instance, I'm unable to call the correct instance for each iteration in the for loop. Any ideas? -
Single item in Wagtail StreamField
How do I create a dynamic content block on a Page model. Let's say I want a block representing a google map. So, I aggregate this StructBlock as the zoom level, lat, and lng with the template rendering the block. The idea is to avoid user's actually having to enter lat / lng in the admin and just use the search maps provides and set the lat / lng dynamically this way. The only way I know of to add this is wrapping the block in StreamField then adding ti as a stream field panel. However, this allows multiple to be added when I only want one. -
Django admin save inline form instances with no fields
I'm attemping to add copies of a book through a books admin page. Inside models.py I have: class Book(models.Model): ... class BookCopy(models.Model): book = models.ForeignKey( 'Book', related_name='copies', on_delete=models.CASCADE ) # No additional fields here class BookCopyInline(admin.StackedInline): model = BookCopy can_delete = False verbose_name_plural = 'copies' Inside admin.py I have the following: class BookCopyInline(admin.StackedInline): model = BookCopy can_delete = False verbose_name_plural = 'copies' @admin.register(Book) class BookAdmin(admin.ModelAdmin): inlines = (BookCopyInline,) @admin.register(Book) class BookAdmin(admin.ModelAdmin): model = Book list_display = ('isbn', 'title', 'subtitle') prepopulated_fields = {'slug': ('title',)} inlines = (BookCopyInline,) I'd like to be able to add book copies inside the Books Admin page. But since the BookCopy model defines no additional fields the instances are never saved. The image below demonstrates the issue I'm facing, new rows can be added, but when save is clicked, no BookCopies are created Is there a way to have the admin save the instances regardless? -
Validation errors not showing up
So I'm stuck on why validation errors aren't showing for this particular form. They are showing up fine on all my other forms, but not this one. I can empirically see the validation at work because when office_street_address is none, the form is not saving. But the form.non_field_error doesn't seem to have any errors. forms class PremiumAgentForm(forms.ModelForm): class Meta: model = Agent exclude = ['field1', 'field2', ...] def __init__(self, *args, **kwargs): super(PremiumAgentForm, self).__init__(*args, **kwargs) for visible in self.visible_fields(): visible.field.widget.attrs['class'] = 'form-control' def clean(self): cd = super(PremiumAgentForm, self).clean() a = cd.get('office_street_address') if a == None: raise forms.ValidationError("Error") return cd html <form class="row justify-content-center" enctype="multipart/form-data" method="post"> {% csrf_token %} {% for error in form.non_field_errors %} <p style="color: red">{{ error }}</p> {% endfor %} {% if form.non_field_errors %} <p style="color: red">there are errors</p> {% else %} <p>no errors</p> # This is always displayed. {% endif %} <div class="col-sm-4"> {% for field in form %} <div class="form-group pb-3"> {% for error in field.errors %} <p style="color: red">{{ error }}</p> {% endfor %} {{ field.label_tag }} {{ field }} {% if field.help_text %} <small class="form-text text-muted">{{ field.help_text|safe }}</small> {% endif %} </div> {% endfor %} <button class="button2"><span>Submit</span></button> </div> </form> views.py def edit_profile(request): if request.method == … -
How to convert Dic Post to Serialized Object in Django?
How to convert Dic Post to Serialized Object? I do not know if the output is correct. Someone could help with this doubt. Thank you very much. Post html form { 'pergunta[4][item][11][quarto][0]': 'AA', 'pergunta[4][item][11][quarto][1]': 'AA', 'pergunta[4][item][11][segundo][0]': '123' } As should { 'pergunta':[ 'item': [ {'quarto':[ 0: 'AA', 1: 'AA' ]}, { 'segundo': [ 0: '123' ]} ] ] } -
Django search by GenericRelation (contenttypes)
For ask question I'll show the models, in case the issue can be made easier by changing their architecture, first. So I store all names which have two on more translations in common (contenttypes) model. Translations sets by user so l10n is not acceptable for this. class L10nString(models.Model): language = models.CharField(max_length=5) string = models.TextField(blank=True) primary = models.BooleanField(default=False) content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) object_id = models.BigIntegerField() content_object = GenericForeignKey('content_type', 'object_id') Other model for staff class AbstractPerson(models.Model): class Meta: abstract = True def save_name(self, language, string): if not L10nString.objects.filter(string=string).exists(): l10n_string = L10nString(content_object=self, language=language, string=string) l10n_string.save() # name stored as L10nString name = GenericRelation(L10nString, related_query_name='name') bio = RichTextField(blank=True) class Staff(AbstractPerson): birthdate = models.DateField(null=True) In my View, I get string with contain name. I need to find this name in L10nString model (of cause only for Staff model) and return JSON contain pairs id:name My own realisation is really bad. Get strings id: l10n_string = L10nString.objects.filter(string__icontains=request.GET.get("q"))[:MAX_OFFSET].values_list('object_id', "string") Find all ids and map as JSON: q = list(map(lambda x: {"id": x[0], "text": x[1]}, zip(Staff.objects.filter( id__in=(x[0] for x in l10n_string))[:MAX_OFFSET].values_list( "id", flat=True), (x[1] for x in l10n_string)))) So, it's working but... I make two request to DB and solution is ugly. Could it be more correct? -
manage.py test error in Django involving django.db.utils.OperationalError
I receive the following error when I run python manage.py test django.db.utils.OperationalError: could not translate host name "db" to address: nodename nor servname provided, or not known My docker-compose.yml looks like this: version: '3' services: db: image: postgres ports: - "5432:5432" web: entrypoint: /entrypoint.sh build: . command: python3 manage.py runserver 0.0.0.0:8000 volumes: - .:/code ports: - "8000:8000" depends_on: - db My dockerfile looks like FROM python:3 ENV PYTHONUNBUFFERED 1 RUN mkdir /code WORKDIR /code ADD requirements.txt /code/ RUN pip install -r requirements.txt ADD . /code/ COPY entrypoint.sh /entrypoint.sh RUN chmod +x /entrypoint.sh Please give me any insight on how to resolve this issue. -
How to get single field as result in django rest framework query?
So I'm setting up a REST API in Django and can't figure out how to return the result for a single field in a model with an http query. For example, let's say that our model User has the attributes 'id', 'username', and 'email'. It's easy enough to return all related fields for that model instance, but how would I go about getting a single field from a query? Something like myapp/api/user/1?username or myapp/api/user/1/username is what I'm looking for but I cannot find any good answers. -
Django strip a string to datetime
I have date and time in a string in such a format 2016-09-01 00:00:00 How to change this string to a DateTime and assign to a DateTime field inside a model? -
Prefix Django base URL pattern
My service implemented in Django is hosting iCal calendar files. I want this files to be opened as a webcal stream, but this requires URL to be composed in a certain way so that browser/system/another service understands what should it do to handle this file properly. The URL should look like this: webcal://myservice.com/icalfile, but the URL pattern in Django starts only at myservice.com base url, for example: url(r'^/icalfile$', views.ReturnICS.as_view()) is the equivalent of: myservice.com/icalfile Although I can explicitly insert webcal:// to a url for each ical file represented in a template and pass it as variable when rendering view, like this for instance: ics_url = 'webcal://' + icalfileurl I'd very much like to find a way to compose a full url pattern that already has 'webcal://' part included, something like: url(r'^webcal://*/icalfile$', views.ReturnICS.as_view()) * – is where base URL is. but Django does not recognise this construction. -
Django channels - custom routing does not seem to work
I'm working on understanding Django's channel package and want to try and have more flexibility when it comes to the different things one can do on the same page. I'm stuck at trying to figure out why my webSocketBridge does not work as it looks like it should work looking at other examples. Here is the app routing: channel_routing = [ route('websocket.connect', ws_connect), route('websocket.disconnect', ws_disconnect), ] custom_routing = [ route("chat.receive", receive_chat_message, command="^send$"), ] The main routing that the settings.py read from: channel_routing = [ include("ChatApp.routing.channel_routing", path=r"^/chat/stream/$"), include("ChatApp.routing.custom_routing"), ] The consumer, not that it's even being called: @channel_session_user def receive_chat_message(message): log.debug("ws recieved a message") try: data = json.loads(message['text']) except ValueError: log.debug("ws message isn't json text") return if 'message' not in data: log.debug("ws message unexpected format data=%s", data) return if data: room = Room.objects.first() log.debug('chat message handle=%s message=%s', message.user, data['message']) reply = Message.objects.create( room=room, handle=message.user.username, message=data['message'], ) Group('users').send({ 'text': json.dumps({ 'reply': reply.message, 'handle': reply.handle, 'timestamp': reply.formatted_timestamp }) }) Then there is the current JS tied to all of this: $(function () { // Correctly decide between ws:// and wss:// let ws_path = "/chat/stream/"; console.log("Connecting to " + ws_path); let webSocketBridge = new channels.WebSocketBridge(); webSocketBridge.connect(ws_path); webSocketBridge.listen(function(data) { if (data.username) { const username = … -
Form is not saving user data into database Django
Python noob here trying to learn something very simple. I'm trying to create a basic form that takes some personal information from a user and saves it into a sqlite3 table with the username of the user as the primary key. My models.py looks like this: class userinfo(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, primary_key= True, on_delete=models.CASCADE) name = models.CharField(max_length = 200, blank = True) email = models.EmailField(max_length= 300, default = 'Null') phone = models.CharField(max_length= 10, default = 'Null') def __unicode__(self): return self.user forms.py: class NewList(forms.ModelForm): class Meta: model = userinfo exclude = {'user'} views.py def newlist(request): if request.method == 'POST': form = NewList(request.POST) if form.is_valid(): Event = form.save(commit = False) Event.save() return redirect('/home') else: form = NewList() return render(request, 'home/newlist.html', {'form': form}) html: {% load static %} <form action="/home/" method="post"> {% csrf_token %} {{ form.as_p }} <input type="submit"> </form> urls.py too, but I don't know how that would help: urlpatterns = [ url(r'^newlist/$', views.newlist, name='newlist') ] So when I go to the url, I see the form. I can then fill the form, but when I submit the form, the data doesn't go into the database. What am I doing wrong here? Thanks in advance! -
django send_mail [Errno 111] Connection refused
I have a problem via sending my emails from django: Django Version: 1.11.3 Exception Type: error Exception Value: [Errno 111] Connection refused Exception Location: /usr/lib/python2.7/socket.py in create_connection, line 571 Python Version: 2.7.6 settings.py EMAIL_USE_TLS = True EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'mymail@gmail.com' EMAIL_HOST_PASSWORD = '******' EMAIL_PORT = 587 views.py ... from django.core.mail import send_mail ... def testmail(request): send_mail('subj2', 'message', 'mymail@gmail.com', ['receiver@gmail.com']) return HttpResponse('ok') But, when I try to send message from console: python manage.py shell from django.core.mail import send_mail send_mail('subj2', 'message', 'mymail@gmail.com', ['receiver@gmail.com']) It's working, and I sucessfuly receive my message. -
Django two parameter filter query with foreign key
My Django models look like this: class User(models.Model): userid = models.CharField(max_length=26,unique=True) #some more fields that are currently not relevant class Followers(models.Model): user = models.ForeignKey('User',related_name='usr') coins = models.IntegerField() followers = models.CharField(max_length=26, null=True, blank=True) I would now like to make a filter query in my Followers table selecting every entry where users have ID x and followers have ID y (I expect to get one result from the query). To visualize what I have tried and know won't work is this: queryfilter = Followers.object.filter(followers=fid, user=uid) and this: queryfilter = Followers.object.filter(followers=fid, user__userid=uid) In the end I would like to access the coins: c = queryfilter.coins It may be possible that I cannot do it with one single query and need two, since I am trying to do a filter query with two tables involved. -
Django delete S3 bucket on button click
I have a list of S3 buckets on AWS. Each bucket's name is displayed and I'm trying to implement a delete button using django. The problem I'm having is that I'm not sure yet how to get and pass bucket name variable to the delete function I have. Here's what I've done so far: DeleteBucketView.py class deleteBucket(TemplateView): template_name = "project/delete_bucket.html" def deleteBucket(self, name): s3 = boto3.resource('s3') bucket = s3.Bucket(name) bucket.delete() S3.html <div class="s3Items"> {% for bucket in buckets %} <div class="s3Name"> <div id="left"> <a href="#"><h4 id='s3ItemName'>{{ bucket.bucketName }}</h4></a> </div> <div id="right"> <ul id='s3ItemDesc'> <li>{{ bucket.createdAt }}</li> <li>{{ bucket.totalSize }}/4GB</li> <li> <form method="post" action="{% url 'project:deleteBucket' %}"> {% csrf_token %} <button type="submit" name="button" class='button delete'>Delete</button> </form> </li> </ul> </div> </div> {% endfor %} deletebucket.html is empty as I'm not sure what I could enter there. I need to call function deleteBucket when I click delete button, however I would need to pass bucket's name to the function as well. I think I also need to define post in deleteBucket view but I'm not sure how to go from there. How do I pass the bucket's name into the function and make this work? Do I need to add anything in deleteBucket.html? … -
Django mptt category/post URLS
Hello everyone I am trying to make a website for myself using django and mptt but I have a problem configuring the URL (and using get_absolute_url). My idea is that I want to access my posts like this: (category_slug)/(post_slug) Here is my Post and Category models: class Post(models.Model): title = models.CharField(max_length=120, unique=True, db_index=True) slug = models.SlugField(max_length=120, unique=True) author = models.ForeignKey(settings.AUTH_USER_MODEL) content = HTMLField('Content') category = TreeForeignKey('Category', null=True,blank=True) def __str__(self): return self.title def save(self, *args, **kwargs): if not self.slug: self.slug = get_unique_slug(self, 'title', 'slug') super().save() def get_slug_list_for_categories(self): try: ancestors = self.category.get_ancestors(include_self=True) except: ancestors = [] else: ancestors = [ i.slug for i in ancestors] slugs = [] for i in range(len(ancestors)): slugs.append('/'.join(ancestors[:i+1])) return slugs @permalink def get_absolute_url(self): return ('view_post', None, {'slug': self.slug}) class Meta: verbose_name_plural = "Posts" db_table = 'cms_post' ordering = ['-posted'] class Category(MPTTModel): title = models.CharField(max_length=120, unique=True, db_index=True) slug = models.SlugField(max_length=120, unique=True) parent = TreeForeignKey('self', null=True, blank=True, related_name='children', db_index=True) meta_keys = models.CharField(max_length=80) meta_desc = models.CharField(max_length=140) def __str__(self): return self.title @permalink def get_absolute_url(self): return ('view_post_category', None, {'slug': self.slug}) class MPTTMeta: order_insertion_by = ['title'] class Meta: verbose_name_plural = "Categories" db_table = "cms_post_category" unique_together = (('parent', 'slug')) My view for listing categories and single post (example from a blog): def view_post_category(request,hierarchy= None): … -
What could be wrong running django locally, in terms of session caching?
There seems to be a problem with redis, even though i've ran the same application successfully with the same django settings. In settings.py, my database settings are as such: ** if os.environ.get('REDIS_URL'): CACHES['default'] = { 'BACKEND': 'django_redis.cache.RedisCache', 'LOCATION': os.environ.get('REDIS_URL')} DATABASES = { 'default': dj_database_url.config( default='postgres://localhost:5432/saleor', conn_max_age=600)} ** I get this error: saleor.W001: Session caching cannot work with locmem backend HINT: User sessions need to be globally shared, use a cache server like Redis. -
Upgraded to 2.0, url matching broke
I've just upgraded to 2.0. Had to specify on_delete for foreign keys which worked fine, but url matching broke when I tried to change my urls to use the new simpler matching ```NoReverseMatch at / Reverse for 'pie_run' with arguments '(UUID('bbc3bfb9-6ffe-48b2-9bb8-715c5d4784ef'),)' not found. 1 pattern(s) tried: ['/']``` I haven't changed anything else, the regex version still works fine. The above is thrown when the template does {% url 'pie_run:pie_run' pie_run.pie_run_id %} I tried to debug and it seems to me that reverse() doesn't recognise <pie_run_id> as an argument. Source code: https://github.com/StefanoChiodino/py-pie/blob/master/pie_run/urls.py https://github.com/StefanoChiodino/py-pie/blob/master/pie_run/templates/pie_run/index.html https://github.com/StefanoChiodino/py-pie/blob/master/pie_run/views.py -
Authentication with case insensitive username
I have created login model in Django and I am using username for authentication(using default authenticate()), but at present the username is case-sensitive. Is there a way in django that while authenticating the case-sensitivity of username is not considered? -
getting django.core.exceptions.ImproperlyConfigured error
I installed mysqlclient on mac, but still getting error in Pycharm, I can't understand what's wrong: Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x1058c7840> Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/mysql/base.py", line 26, in <module> import MySQLdb as Database File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/MySQLdb/__init__.py", line 19, in <module> import _mysql ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so, 2): Library not loaded: @rpath/libssl.1.0.0.dylib Referenced from: /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_mysql.cpython-36m-darwin.so Reason: image not found During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper fn(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run autoreload.raise_last_exception() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py", line 251, in raise_last_exception six.reraise(*_exception) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise raise value.with_traceback(tb) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper fn(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/apps/registry.py", line 108, in populate app_config.import_models() File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/apps/config.py", line 202, in import_models self.models_module = import_module(models_module_name) File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 994, in _gcd_import File "<frozen importlib._bootstrap>", line 971, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 665, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 678, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/contrib/auth/models.py", line 4, in <module> from django.contrib.auth.base_user import AbstractBaseUser, … -
Override email template in django rest-auth
How can I override the reset password email template from django rest-auth? Here are the urls I'm talking about: url( regex=r'^contrib/password_reset/$', view=password_reset, name='password_reset' ), url(r'^api/rest-auth/password/reset/$', auth_views.PasswordResetView.as_view(), name='rest_password_reset'), -
Django-channels - message.user is allways AnonymousUser instance
I'm very new to Django-channels. I'm creating a notification system. If someone get's message, this message appears immediately somewhere in the header. The problem is that I can't recognize user. message.user isAnonymousUser` instance allways. In base.html: socket = new WebSocket("ws://" + window.location.host + "/notifications/"); socket.onmessage = function (e) { alert(e.data); }; socket.onopen = function () { socket.send("Opened"); } In routing.py: @channel_session_user_from_http def message_handler(message): print message.user # ALLWAYS ANONYMOUS print(message['text']) message.reply_channel.send({"accept": True}) channel_routing = [ route("websocket.receive", message_handler) ] How to recognize the user? -
Java Script each loop using chart.js and REST API django
I am using chartJs in my Django application. I am trying to loop through different users, for some reason it does not render my graph. I guess I am doing something wrong with the javascript but I don't know what .. could you please help me to figure it out ? here is my code : html: <script> var endpoint = 'api/chart/data' $.ajax({ method: "GET", url: endpoint, success: function(data){ console.log(data) //Labels comming from website.views// team = data.team_name labels_info = data.labels data_array = data.data_array var random_color = 'rgb(' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ',' + (Math.floor(Math.random() * 256)) + ')'; jQuery.each(team , function(index, value){ var dataset_list = [{ data: data_array, label: value, backgroundColor: random_color(), },] }) var ctx2 = document.getElementById("info_process").getContext('2d'); var info_process = new Chart(ctx2,{ type: 'radar', data: { labels: labels_info, datasets: dataset_list, }, options: { scale: {display: true, ticks: { beginAtZero: true, } }, responsive:true, maintainAspectRatio: true, } }); error: function(error_data){ console.log("error") console.log(error_data) } }) </script> view.py class ChartData(APIView): authentication_classes = [] permission_classes = [] def get(self, request, format=None, *args, **kwargs): team_name = Project.objects.get(id=kwargs['pk']).team_id.team_name labels = [janv,fevrier,mars,avril] data_array = [1,3,4,5] data ={ "team_name":team_name, "labels"=labels, "data_array"=data_array } return Response(data) -
AJAX, Django and HTML Select?
I have a form with many fields, but I have two selects, one for select the country and one for select the cities of the country that I selected. I want to make this: When I choose the country in the first select I want to change the cities of the second select filtered by the id of the contry that I selected. Here is my Models.py class country(models.Model): country_name = models.CharField(max_length=264) def __str__(self): return self.country_name class country_cities(models.Model): city_name = models.CharField(max_length=264) country = models.ForeignKey(country) def __str__(self): return self.city_name And Here is my HTML Form: <form method="post"> <input type="text" name="username"> <select name="country" onchange="listCities()"> {% for country in countrylist %} <option value="{{ country.id }}">{{ country.country_name }}</option> {% endor %} </select> <select name="city" id="citylist"> <!--HERE IS WHERE I WANT TO LIST JUST THE CITIES OF THE COUNTRY THAT I SELECTED--> </select> </form> How do I make my view and what libraries I have to import in my views.py? Also I'm not sure if my AJAX library or my script is correct. AJAX: <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"> </script> SCRIPT: <script type="text/javascript"> function listCities() { var countryid = $("[name='country']").val(); $('#citylist').html(''); $.ajax({ type: "POST", data: "countryid="+countryid, url: "editprofile/", success: function(result) { var resultObj = JSON.parse(result); var dataHandler …