Django Image Upload - django

I am trying to upload an image using a form with Django. First off, I don't know if I should be doing this with django or a combination of jQuery and Django. Second, I am looking for a simple tutorial using 1.7 and can't seem to find one. Is there something like this for version 1.7. I'm just looking for something super simple and then I can expand from there.

Code from your link should work perfectly in django 1.7.

The linked tutorial will work for Django 1.7, along with pretty much any tutorial. The one thing you're going to run into that's different in 1.7 is that the migrations are built into Django now instead of using a 3rd Party App called South.
You definitely should be using django forms to upload the image, it's really simple once you get the hang of it - it's just like another field. You definitely should not use a combination of JQuery and Django.
If Django can't do what you're wanting to accomplish, take a look at Django Crispy Forms. I would suggest getting an understanding of just using Django image uploading first through, regardless.
Hope this helps. Also take a look at the Official Documentation of file uploads, if you haven't already.

Related

Best Way To Serve Images in Django 3.0?

So I 'm working on a project in django - it's like a variation of a blog. There will be 4 mini blogs within the website and the admin for each can create new posts - so they can also add an image to their post.
Now that django has recently been update (django 3.0 is here), I was wondering, what is the best way to store and serve these images in production? Could someone maybe link to a part in the documentation? I don't think this will come under staticfiles will it? I searched the documentation with keywords like "Media", "Serving images" etc but didn't really find much.
EDIT: The project is quite small and I want to save files inside a folder of my django project.

Integrating Django tutorial example Polls app and django-registration

I'm learning Django on Ubuntu 13.04, Python 2.7, Django 1.5, Postgres 9.2,
Bootstrap 3.0. I'd like to achieve a combination of the tutorial example Polls app with django-authentication.
As my first effort I got the Polls app working from the Django 1.5 tutorial. I then installed django-registration 1.0 and these templates to make it work. I chose that package for authentication as opposed to django-allauth as a result of my question on authentication framework.
Now I want to integrate Polls and django-registration to record a set of results per user. After the poll results have been collected the admininstrator uses Django Admin interface to run a script to analyse the results (e.g. compute some statistics) and send an email to a subset of all users.
I briefly looked at two existing projects that looked like could get me there out of the box.
Light Bird's Questionnaire App was too complicated using a custom library of modular class based views. I'd like to keep it as simple as possible, using as much of out-of-the-box Django 1.5 functionality as possible for ease of maintenance and initial design.
Pinax web framework on top of Django, although a great idea, seems to be stuck in dark ages of 2011 with latest code supporting only Django 1.4 and Bootstrap 2.x. Starter projects don't look that useful and documentation isn't flash either.
Based on the above it looks like I'll have to do the integration of Polls and registration manually. At first pass I was thinking roughly the following:
The poll & choice could be simplified down to just a numeric answer to a question.
At database level we would need a separate table.
The primary key would be the userid.
Each column would store one answer per.
I'm guessing this would need a class PollsResults in model.py that would include defining the primary key as User, which should exist via django-registration.
Exactly how to do that and what follows gets a bit hazy to me at the moment.
I'm sure the above is a simple exercise for a Django developer. Could anyone give me some starting hints or even better an existing project that does something similar?
It looks like you're slightly underestimating the power of using a framework such as django. For example, you don't really need to worry too much about tables in the database or what will be their primary keys, because django's Object Relational Mapper (ORM) takes care of a lot of that for you.
If you want to connect two models (database tables) in django you can use a foreignkey like this:
class ThingOne(models.Model):
name = models.CharField(max_length=50)
class ThingTwo(models.Model):
thing_one = models.ForeignKey('ThingOne')
The quotes around 'ThingOne' in my ForeignKey are actually unnecessary because the ThingOne model has already been defined, but I like to use quotes anyway because it means your ForeignKeys will also work for models defined below (in your code) the model linking to them.
You therefore just need to add a relationship between your Polls and User models. If one user might have many poll results you should probably use a ManyToManyField instead of a ForeignKey but the principle is the same. That should be enough to get you started.

Django: Is there a django blog or cms engine that have all wordpress features?

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.

Django Integration with SOLR and NUTCH

I am using SOLR with NUTCH
I have successfully configure both and Solr is giving me the desired results
Now i want to integrate this in my Django project
Can anyone suggest me how to do it ...
it depends on what you need:
IF YOUR SOLR INSTANCE IS BOUND TO THE DJANGO'S MODEL
you probably are looking for django-haystack: it's pretty easy to setup and to use inside your django views, but it's not suited for huge amount of data
IF YOU'RE USING SOLR WITHOUT ANY RELATION TO DJANGO MODELS
this means that your results are retrieved as pure array, and you just need a python interface to solr. you have some choices
pysolr
solrpy
sunburnt (i'm using this)
you have to try them out and find out which one satisfies you more (check their websites too, to see if the project is mantained. also, stumble into their source code, to check if there's all you need). being a python interface implies that you have to do a little bit more of work inside your views
i hope this can help you

Django Photologue Tutorial

I have a hard time understanding how photologue works exactly.
Is anybody aware of a Example Project Tutorial where I can display a gallery via Django-Photologue. Where Imagelinks are stored in a database?
Or how can I achieve that in Django?
Or what else is out there to create a decent Photo Display?
Thanks for the time!
The best way to get started with photologue is to start a new django project, and follow the installation instructions. Then, load up the django admin and start adding photos and creating galleries. You should be able to get a good understanding of Photologue that way.
Photologue is based around the concept of having gallerys of images with different photo sizes and effects. It's great if you want to show a gallery of images. If you are looking to intergrate images into your own apps, you might find ImageKit much more useful. I think it's based on Photologue, but instead of giving you automated photo galleries it provides hooks that you can use to do manage photos programmatically.
Here is an example project by the author of photologue:
https://github.com/jdriscoll/django-photologue/tree/master/example_project