Beautifulsoup django integration - django

still a newbie so I have a bunch of questions which might seem silly. However, here I go:
as a project to learn python, I decided I would start with something simple. The idea I had was to go to craigslist and find the prices of motorcycles, go through the first 10 pages of each city and give a mean, median and price trends. the result of that work can be found here (http://craigslistcompanion.co.nf/) as well as the codes.
now in order to make things better i decided that i should let the user input what they want (motorcycle/ car/ bikes) and from where (sfbay/ austin etc) and get the same results as shown in that page. as i started looking into it i was told that learning django would be a good place to start and i have been trying to do that for the last couple of days. however, what i have learn so far is mostly setting up databases and handling them.
I was wondering if there is a tutorial somewhere which will show me how to take input from the user and then manipulate it. i want to do this completely using python/ django.
for example lets say i want the user to input their first and last name and then try to play with that string and output something. how would i go about doing that?
thanks

First some clarification. Do you want to develop a web interface for your users? If so, then Django is a great start. The Django Book is a very good introduction to Django and teaches you with examples. The task of getting user information, validating it, manipulating it and saving it in a database is the most basic of task and it is explained well in the book.
The next thing is web scraping craigslist. From how you structured your question, it seams that you have solved that part of the problem. right?

Related

scroll websites with django

I'm currently working on a simple scroll website with nothing really difficult (I could almost use plain html/css/javascript but it's a bit of practicing and I will maybe add a blog). And as it is simple I was wondering how to do it properly with Django.
So here is my question, I have a homepage template that is actually the website and I don't really get how I split my different part in different apps.
For exemple I have a contact form, do I need to split it in another app and then include it in the basic template ? I want to add a galery with image in a database, do I create an app for that ?
And the other question that goes along is how do I code an app that is not returning httpresponse but just html to put it in another template and do I still need views ? I would like to do a bit like a standard form in django where you do :
form.as_p or form.as_table
so maybe:
galery.as_slideshow
So my questions are quite novice and open but someone could give me some reading to get going, I would be really happy !
This is a question a lot of people struggle with and it seems like there are a lot of varying opinions out there.
I've found that the best way to really determine the appropriate answer for each case is to really distill the feature into individual requirements and group them by feature sets while keeping an eye out for additional uses outside of the project actively being worked on.
There is nothing which says you can't build your project to include a single app containing all of the modules you would need. Doing so seems like it would make your development easier initially right? So, the question to ask then is "What if I want to reuse (insert feature set here) in another unrelated project a year from now after I've already forgotten about the weird stuff I did to make it work originally?". Asking yourself that question forces you to think about your features in a much broader context and I think 99% of the time you will realize that a "Contact Form" requirement can actually become quite complex and really should be split up into at least one separate app (i.e. User Creation, Profile Management, Email Subscription, etc...)
Here is a link to a video about this very topic which I found to be useful in figuring out my way through this question:
https://www.youtube.com/watch?v=A-S0tqpPga4
I know this is not really a hard-line answer to your question but I hope it helps point you in the right direction.

Ember Way to Add Rss Feed without third party widget, Front-end only

I am using Ember 3.0 at the moment. Wrote my first lines of code in ANY language about 1 year ago (I switched careers from something totally unrelated to development), but I quickly took to ember. So, not a ton of experience, but not none. I am writing a multi-tenant site which will include about 20 different sites, all with one Ember frontend and a RubyOnRails backend. I am about 75% done with the front end, now just loading content into it. I haven’t started on the backend yet, one, because I don’t have MUCH experience with backend stuff, and two, because I haven’t needed it yet. My sites will be informational to begin with and I’ll build it up from there.
So. I am trying to implement a news feed on my site. I need it to pull in multiple rss feeds, perhaps dozens, filtered by keyword, and display them on my site. I’ve been scouring the web for days just trying to figure out where to get started. I was thinking of writing a service that parses the incoming xml, I tried using a third party widget (which I DON’T really want to do. Everything on my site so far has been built from scratch and I’d like to keep it that way), but in using these third party systems I get some random cross domain errors and node-child errors which only SOMETIMES pop up. Anyway, I’d like to write this myself, if possible, since I’m trying to learn (and my brain is wired to do the code myself - the only way it sticks with me).
Ultimately, every google result I read says RSS feeds are easy to implement. I don’t know where I’m going wrong, but I’m simply looking for:
1: An “Ember-way” starting point. 2: Is this possible without a backend? 3: Do I have to use a third party widget/aggregator? 4: Whatever else you think might help on the subject.
Any help would be appreciated. Here in New Hampshire, there are basically no resources, no meetings, nothing. Thanks for any help.
Based on the results I get back when searching on this topic, it looks like you’ll get a few snags if you try to do this in the browser:
CORS header issues (sounds like you’ve already hit this)
The joy of working with XML in JavaScript (that just might be sarcasm 😉, it’s actually unlikely to be fun)
If your goal is to do this as a learning exercise, then doing it Javascript/Ember will definitely help you learn lots of new things. You might start with this article as a jumping off point: https://www.raymondcamden.com/2015/12/08/parsing-rss-feeds-in-javascript-options/
However, if you want to have this be maintainable for the long run and want things to go quickly and smoothly, I would highly recommend moving the RSS parsing system into your backend and feeding simple data out to Ember. There are enough gotchas and complexities to RSS feeds over time that using a battle-tested library is going to be your best way to stay sane. And loading that type of library up in Ember (while quite doable) will end up increasing your application size. You will avoid all those snags (and more I’m probably not thinking of) if you move your parsing back to the server ...

Learning django with "Django from the Ground Up": Outdated?

I've discovered this excelent series of video-tutorials, the "Django from the Ground Up", but as it was uploaded on 09/08 I was wondering if it's still worth going through it or I will teach me and "outdated" way of working with django.
What do you think?
thanks in advance,
Ignacio.
I haven't watched the video, but I suspect it's out of date.
If the tutorial is from 2008, then it's probably based on Django 1.0. As I write this is 2012, the latest version is Django 1.4.
Django is pretty good at not breaking things between versions, however there are changes you have to make to get a 1.0 project working in 1.4. If you're new to Django, you might end up wasting a lot of time struggling with the changes.
Although I personally don't know "Django from the Ground Up", I would not suggest using 2-3 year old tutorials about in-depth parts of Django.
A large part of Django is still the same (forms for example), but a lot of cool things have been added/modified in the Django ORM and Django Admin. So it really depends on what you're learning. If it's a simple part or just an initial look than it would probably be a good starting point.
If you want in-depth knowledge than you will need something more recent.
I think teamtreehouse has some django videos (though I have never seen them), but I would suggest you purchase the django book written by the django creators "The Definitive Guide to Django: Web Development Done Right". But be sure to get the second edition. You should also take a look at "http://harry.pythonanywhere.com/tutorial/1/" he has some very good tutorials you should work through. If however you really want videos try http://www.youtube.com/user/programmersbook he has has whole collection of django tutorials. The only downside on these is that the first 16 videos have no sound.
Anyway's good luck with django!

Please help my learning in Django

Hi All I am new on Django and python.I want to wirte program with Django .So please share me useful ideas and concept.How can I set up djanog in my window OS.
I little confuse and occur some errors while I read ebooks.
Share me with all experiences please in step by step.
Thank for all
http://www.djangobook.com is your friend. Free, well written and generally ace.
First, if you're new in python read dive into python, you must use python 2.5 or 2.6 not 3 (for django at least)
For windows here's a good tutorial. Then read the djangobook
For further information you can read Pro Django
And remember the oficial docs is very well written.
This may help you to start
This is great resource for you Getting Started with Django
Enjoy.
The first thing you should do is get yourself a project, it can be anything. The classic django-learning project is a blog.
Python is fairly easy to learn once you have some programming experience. I recommend that you go through the official tutorial. This google class also looks pretty good. You don't need to know the standard library all that much -- just enough python to find your way around whenever you need something. I'd say you can pick up python in a few afternoons of work.
After that, go through the django tutotial to get an idea of how to get started. Then start with your project using the docs which are quite good. They also contain an overview and installation section which may be handy. After you've gotten your feet wet, read the django book and then go fix all the things that could be better about your project.
Just like with any kind of programming, the key is to be constantly practicing and improving your code.

What is the quickest way to a very simple blog? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 months ago.
Improve this question
I am about to start a new project and would like to document its development in a very simple blog.
My requirements are:
self-hosted on my Gentoo-based LAMP stack (that seems to rule out blogger)
Integration in a django based website (as in www.myproject.com/about, www.myproject.com/blog etc rather than www.myproject.com and a totally different site at blog.myproject.com)
very little or no learning curve that's specific to the blog engine (don't want to learn an API just to blog, but having to get deeper into Django to be able to roll my own would be OK) According to the answers so far, there is a chance that this excludes Wordpress
Should I
a) install blog engine X (please specify X)
b) use django to hand-roll a way to post new entries and a page on my website to display the posts in descending chronological order
Install Wordpress. It is the most common engine for a reason. It's PHP but will play just fine in your environment.
If you're the perfectionist kind, roll your own.
It isn't that hard
You learn something useful
You'll get exactly what you want and need
Be warned that you may run into a quagmire fighting comment spam, fixing security holes, etc. But it'll probably be a fun project.
If you are the practical type and ready to face some integration pain, use an existing engine like WadcomBlog (Python) or PyBlosxom, or something completely different like MovableType or WordPress.
Here's a simple Django blog example to get you started.
Some pros and cons of rolling your blog engine this article by Phil Haack.
Jeff Croft apparently rolled his own as well.
I've tried WordPress recently and am very disappointed. As long as you don't want to customize anything, all is well. But imagine you want to install a plugin to handle Markdown editing. There the trouble begins. The plugin architecture of WordPress is seriously screwd up. In the case of Markdown, this means that no good solution exists. The existing plugin is a series of (quite well-documented) hacks that fall apart at a hard stare.
I never intended to write the least bit of code for WordPress but the last few days, I've been knee-deep in PHP the whole time, hacking plugins as well as the WordPress core in order to make it work for my special scenario (which really isn't all that special, I'm just a perfectionist). Which is a pity, because the documentation of WordPress is more than just patchy. I don't use it anymore, I grep for functions and read the source. All in all, one of the less enjoyable OpenSource projects.
You can spend hours if not days customizing Wordpress with plugins, themes, etc...
I would go with a 0 installation solution, such as blogger (https://www.blogger.com/start)
You can even use our own domain name with it if you need do.
EDIT: Plus, if you ever get slashdotted, digged or redditted, google can handle the traffic, your server probably can't.
For me, Wordpress is still the quickest & simplest to setup and get going. It can be extended to do pretty much anything or you can keep it real simple. Runs on PHP, but unless you want to write plugins for it, you never need to write code
Have a look at Blosxom. It's file-based, so no crufty database. The basic idea has been ported to different languages, pyblosxom is in Python.
I use PyBlosxom for my personal blog, and I think it is pretty useful if you need something minimalistic. The deployment is simple, as you need only the python runtime and cgi. You might want to have some basic knowledge of python at least if you are going to use it, though.
Have a look at Blosxom. It's file-based, so no crufty database. The basic idea has been ported to different languages, pyblosxom is in Python.
I wrote the engine for my personal blog in maybe 6 hours during one weekend, with comments, labels, simplified markup, sitemap, feeds and so on. It was great fun and I learned a lot of Django.
If you decide to go this way, look at generic views, this Django feature will save you much of work (and learn few useful tricks).
I Haven't tried it myself yet (other than the demo), but I've bookmarked Chyrp so that if I ever need to set up a quick & simple blog (kind of like you're describing) I could try this. So check it out, might be a good option for you.