I want to create simple upload form on my django site where users could upload their gpx files but I want to give them possibility to preview their points and lines on map before they proceed with submiting it.
I have some basic knowledge of working with django forms but I'm not sure how to convert that gpx data and display it on map.
I hope you can tell me at least where to start because I'm completely out of ideas.
Thanks
Well, if you use Django then you could probably extend it with Geodjango which provides you easy and nice way to create geometry fields for your models (points,lines, poligons).
In case you decide to use Geodjango for this purpose then please check my blog post http://ipasic.com/article/uploading-parsing-and-saving-gpx-data-postgis-geodjango/
I've described there process of uploading,parsing and saving gpx file to spatial database (like Postgis).It could help you to get an idea.
I didn't describe how to display it on map but it shouldn't be problem. I would recommend you to use Leaflet or some other javascript mapping library for it.
However, that's to much for writing right now.
I hope that helps.
Related
I would like to ask this question before I start going down unnecessary rabbit holes.
What I want to achieve: Create a simple Django Application that only shows a login form when opening the url.
After login (no user registration required, I just want to use it for myself), I want to be able to access my files.
Files/Folders: I need to look at a ton of data coming from reconaissance from Bug Bounty Programs. So there are a lot of text files and folders.
What would be a good way to display them with Django? Think:
-ProjectFolder
-Subfolder1
-file1.txt
-Subfolder2
-SubSubFolder2
-file1.txt
-Subfolder3
Would be great if I could get some pointers on an easy way on how to acheive this! :)
I have been using formtools in Django to render lengthy forms for my application. I have managed to do this(Fill in forms and submit data into the DB). Something got me thinking, what if I didn't complete all the steps in filling up the forms and want to save the progress and resume filling some other time? I have searched online for such information and haven't succeeded.
First, Is this possible with formtools? If yes, How do I go about this?
Thanks in advance for the help.
Look at formtools.wizard.views.SessionWizardView. As you can guess it uses session storage internally. Also formtools provides cookie-based solution out of the box.
I'm coming from a Kohana background and have asked a couple of questions pertaining an issue I'm having and need to find out how to get this done. I am VERY new to Symfony and Doctrine and love learning new frameworks and correct ways to code. However I'm finding Doctrine ORM frustrating to use yet powerful.
So here is my basic issue and I'll try to be brief. I have a products table and a products_images table. By following the tutorial for Symfony I am already able to create Entities for both and map the relationships, generate getters and setters, create Repositories, and the whole bit. But here is where it gets sticky...
The product_images table only contains the name of the image, not the path, which I will obviously need if I am going to construct and useful href in my html. The products table was populated with products by crawling over the web and obtaining them in that method and as a requirement by the persons that are having me write their website, I am required to keep the images separated into directories that represent where they were crawled from. The location of the images has been changing often so I DO NOT want to store the path in the database.
So to keep my question simple what I need to do, somehow, some way, is to write some logic that examines where the image was crawled from and then construct a path string to pass along to my twig template and then append the image name...all in order to create a valid image tag or href.
My last attempt to find a solution for this was to modify the getter for the image name in the Entity but since I am using createQueryBuilder() to perform some DQL, it appears the getters aren't being used and now I have nothing to go on. I cannot find any documentation on the official Doctrine website that helps me get around this issue and I just need to know how to overcome this. Can anyone help?
if path is static, doctrine has nothing to do with your problem, you can use a constant or a parameter to define it.
then you jsut have to add a getter
getImageWebPath() {
return self::PRODUCT_WEB_PATH. $this->getImageName();
}
If the image is stored in a parameter you can use a lot of tools: twig function wich append the path before your image name, services wich set the path to your entity or directly getting twig parameter... etc
I have a set of top-level configuration data fields that I want to be able to set within django admin for each deployment of my django app. I only want one set of these.
Example fields: site_logo, contact_person, address, facebook_url, twitter_url
The problem is that Django Admin is geared towards tables (lists) of models, so its not a good fit for this type of singular configuration model. I really only want one of these models to exist for the whole site, and to be able to click into it from admin and edit the various fields.
It seems i've come across a 3rd party app in the past to accomplish this but can't find it anywhere. Part of the problem is I'm finding it difficult to find the right words to google. Any ideas?
It looks like django-values will do what you're looking for.
Other possible contenders:
http://github.com/sciyoshi/django-dbsettings (doesn't look maintained)
http://github.com/jqb/django-settings
Have a look at django-livesettings it sounds like it might fit.
Not that i have used it, but i have heard good things about django-constance.
And there are even some more options listed in the Configuration-Grid on Django Packages.
I'm looking at porting a custom-written PHP CMS into Django. One of the features the CMS currently has is an image upload function. I write an article, tag it with information, then choose a photo for it. If the system has any photos which have been added to articles with tags in common with the new one, it will suggest the photo for that article too. If there are no matches then a new image can be added.
In case this doesn't make sense, let's say I tag an article as Bruce Springsteen, The Beatles and Led Zeppelin. Next time I add an article with the tag The Beatles, it should suggest I use the image added for the first article.
What would be the best Django-applicable way to implement this? I've looked at the Photologue app and have integrated it, and I know it has tagging support (the problem here is that I'm using django-taggit, whereas Photologue supports django-tagging). One approach could be simply building it myself -- when a user uploads an article, I run a hook after they save it to associate the tags with the image. I'm just not sure how to then autosuggest an image in the admin tools based on that info.
Any ideas/approaches greatly appreciated.
This is almost certainly something you're going to have to build yourself. Django has a moderate number of libraries out there (that you've clearly already found). Unlike other solutions, it doesn't have a lot of things that get you 100% to your desired solution (whereas something like Drupal might get you 100% of the way there).
What you will probably need to do (at a high level) is something like this:
Create an AJAX view that takes the current tags as an argument and does a query on the existing posts to see what tags match and returns images from those posts.
Use jQuery/javascript on your view to call your AJAX view on the page as tags are added
Use jQuery to update a <div> on your page and show all the images that your view returned
Here is a similar example that might help get you started.
You might look into django-ajax as a helper library for your requests, but it definitely isn't necessary.
The hook between the your image module and any other django module can be implemented using django's contenttypes framework which also provides some useful instance methods for returning related/hooked objects.