I ran into a problem. I am not an experienced a web-dev(front end), so I would appreciate help.
I am required to create a form in the format below to pass in POST to backend:
key:value
{"key":{"key":"value", "key":"value", "key":"value", ..., "key":"value"}}
How can I achieve this?
I am working django web framework.
Thank you
UPDATE:
I figured it out myself. I used JQuery and JS. I created the form manually using JS and then send via JQuery ajax function. Thanks everybody who tried to help.
Start with the tutorial on the docs website perhaps ?
Django tutorial part 1
Forms is especially covered in chapter 4:
Chapter 4 : forms
Related
I am building a blog where users can post and comment using Django, now there is a scenario that I have posts being display on my user page. Using Django for adding a comment it will redirect user to another page. How can I write this using AJAX or AngularJs? I am new to Angular and Ajax and I only need this function specifically.
I appreciate all your help in advance!
I give you link, you follow that if you will got error then put on same question lete know linkajax request
i am new with Django too.but Django Using MVT that means you can use everything in your template and there is no Limits even React or VueJs.
so you can use both.
I want to get the id from url in Django for a python programming language but I face the problem page no found. I want the code for this in the last version in Django because I have it please help me
What I would recommend you to follow the tutorial in the official Django web page.
You will learn Django urls, models and views basics there. https://docs.djangoproject.com/en/2.1/intro/tutorial01/
The answer to your question you can find on the 3rd page of the tutorial:
https://docs.djangoproject.com/en/2.1/intro/tutorial03/#writing-more-views
I've been trying out Ruby on Rails and really like the RESTful approach for the URL's.
Now I'm trying to learn Django and I want to create the same kind of nested URL's as I did with Rails.
Lets say I wanna do this: /categories/12/products/13
This is what I've came up with, but does not seem to work:
url(r'^categories/(?P<category_id>\d+)/products/(?P<product_id>\d+/$)', 'my_app.views.product', name="product"),
How should this be done? Also, how could you use the url template helper for creating this kind of link?
Check out TastyPie. It's a drop-in REST Api for Django similar to what you're used to in Rails and will get you going in the right direction without too much work.
Glad you got it sorted, as TastyPie was mentioned I would also recommend Django REST framework also.
In a template you can use Link title
To create a url in your python code you can use reverse:
from django.core.urlresolvers import reverse
url = reverse('product', args=[category_id, product_id])
I have models with datetimefields and timefields. When the user interacts with these fields in a form they often just need to enter the current time. I need a now link almost exactly like what shows up in the django admin, so the user can just click it and the current time gets put in the field.
I tried looking through the django source but it seems to utilize some frontend javascript which I'm not very familiar with. Is there a simple way to make a widget that can be easily used in a timefield and datetimefield?
So this is not on the admin panel? As in on the site? Then this is not really a question to be posed to Django, I suggest tagging javascript. If you are unfamiliar with javascript, then tag jquery, they have things for this.
In case you're lazy, here's a start:
Here
jQuery premade
Javascript methods
Sorry, but this is more of a UI issue than a Django issue. Hope I helped, though.
as it says, I want django cms engine that have the capabilities of wordpress.
I wanna build something like tutsplus.com network but want it in python/django base.
Django is a framework, so it would be a bit more involved than wordpress for the most part to make something like tutsplus out of the box.
Check out
http://pinaxproject.com/ (I dig pinax) or
https://github.com/nathanborror/django-basic-apps
But you might also want to dig deeper into django based CMSs (via other posts) like:
Django CMS which is the best?
Integrate existing blog code into Django-CMS?
more detailed list of Django based CMSs here:
http://djangopackages.com/grids/g/cms/
Hope that helps.
I have experience with django-cms and I found it very well documented and easy to start with. I still have to figure out good way of putting forms into it.