Im trying to use django send_email function but it fails on authentication. In fact, django returns me message along the lines - ssl not found in this django installation.
I do have ssl-1.15 on my pythonpath and i could import it without errors. So the problem is probably with the certificates, right?
Now is there some kind of tutorial or example for generating those certificates, since the pakcage contains none. Could the problem be elsewhere?
Alan
Have you tried importing ssl-1.15 from within Django? In other words, start ./manage.py shell and try to import ssl-1.15.
Did you find this example? And this one may even be better!
Related
I am am new to Django / Scrapy and well to programming in general. I am trying to make a Django site to help me learn.
What I want to do is Scrape product information from different sites and store them in my postgres database using DjangoItem from Scrapy.
I have read all the docs from both Scrapy and Django. I have searched here and other sites for a couple days and just couldn't find exactly what I was looking for that made the light bulb go off.
Anyway, my question is, what is the standard for deploying Scrapy and Django together. Ideally I would like to scrape 5-10 different sites and store their information in my database.
Scrapy's docs are a little short on information on the best way to implement DjangoItem.
1) Should the Scrapy project be inside my Django app, at the root level of my Django project or outside all together.
2) Other than setting DjangoItem to my Django model, do I need to change any other settings?
Thanks
Brian
I generally put my scrapy project somewhere inside my Django project root folder. Just remember you will need to make sure both projects are in the python path. This is easy to do if you are using virtualenv properly.
Aside from that as long as you can import your Django models from Scrapy i think everything else in the Scrapy docs is very clear. When you import your Django model, the Django settings are set up at that point, this means your database connection etc should all be working fine as long as they are already working in Django.
The only real trick is getting the python path set up properly (which is probably a topic for another questions).
For some reason, my /admin page has made the models I defined un-editable. This is on my deployed server using apache and postgres. I'm logged in as a superuser and the is showing the links like this:
If I look at the same code locally in the development server connected to postgres, it looks like this:
Any idea what could be causing this?
** Update **
So it's not always blocked. I logged in today and I had access for a few actions (I cleaned some bogus email requests from my DB) but then after deleting some rows it got back to the read-only state.
Still no idea what's causing it.
home.models.py:
from django.db import models
from django import forms
from django.utils import timezone
class EmailRequest(models.Model):
email = models.EmailField()
created_date = models.DateTimeField(default=timezone.now())
class EmailRequestForm(forms.Form):
email = forms.EmailField()
home.admin.py:
from django.contrib import admin
from home.models import EmailRequest
class EmailRequestAdmin(admin.ModelAdmin):
list_display = ('email', 'created_date')
admin.site.register(EmailRequest, EmailRequestAdmin)
I don't have a direct answer to your problem, but I do have a few personal insights. First of all, using the Bitnami Django stack is probably a problem. I have used it a couple of times, and I never will again. The setup is definitely NOT ideal, and there is way too little documentation available for it to make your life any easier (wait, wasn't that the whole point of using a Bitnami stack?).
I would start looking through your logs (apache error log and postgres error logs specifically), I bet there is something in there that will point you in the correct direction.
I am sure you are running your development server from your local machine which is setup completely differently from the Bitnami stack. The better solution would be to install everything yourself on a barebones Ubuntu server. Then you will have much more familiarity with the setup.
THE BEST THING you can do, is go learn to use Vagrant. This will help you to maintain a local virtual machine instance, which is identical to your EC2 box. You will log into it using ssh just like the EC2 box, and you will be using it externally, just like the EC2 box. The closer you can get your development environment to your production environment, the easier debugging problems like this will be.
Hope that didn't make your life more difficult (seriously, if you get Vagrant running, your life will become MUCH easier)
See the following solution:
No access to models in admin panel with DEBUG=False
quote:
OK, I've found reason of my problems. It was caused by registering my
models in admin panel from files with models definitions. When I moved
all my registrations to one external file admin.py, then everything
works correctly.
Each time I do a server reload after updating my Django app (running on httpd, using mod-wsgi), the first request is always an internal error.
The problem is always the same -- the app can't import a given model from another app. Unfortunately ImportError is maybe the least helpful of all exceptions in that it doesn't tell you why an import failed, only that it did.
Has anyone encountered this problem, and how was it resolved? Right now there is no workaround, since there are models.py files that rely on this other model. Normally I would assume there was an error in the code, but as the request works every other time I'm guessing it's running into problems for some other reason.
Details:
Django 1.3
running under virtualenv
app that is being imported is not part of main project but included via INSTALLED_APPS
I'd say just give a shot to importing that models module in the manage.py script to see if a preload will work. Also keep an eye out for circular imports (modules importing one another).
Trying to get an oauth module to work I made the pro-move of : manage.py reset sites
This had the effect killing the admin and login functionality of my site.
So, my question is how to I get back to square one and fix what I broke.
Here is my current error when trying to display the admin tool:
DoesNotExist at /admin/
Site matching query does not exist.
Request Method: GET
Request URL: http://mdev.5buckchuck.com/admin/
Django Version: 1.3
Exception Type: DoesNotExist
Exception Value:
Site matching query does not exist.`
I looked at the documentation but I am lost and tired in it:
http://docs.djangoproject.com/en/1.3/ref/contrib/sites/
It seemed to indicate: manage.py syncdb
So, I wonder what to do next...
You don't really need the sites framework if you only run one site from the project, so the easiest fix would be to remove the following item from your INSTALLED_APPS and the error should go away:
'django.contrib.sites'
You can also re-create the missing Site object from shell. Run python manage.py shell and then:
from django.contrib.sites.models import Site
Site.objects.create(pk=1, domain='mdev.5buckchuck.com', name='5buckchuck.com')
Provide SITE_ID=1 in settings.py. This will work.
I went through this problem too, while playing with django-allauth. The application offers the ability to delete sites. If you delete the one designated by the SITE_ID parameter in settings.py, you'll have to point the correct PK of another valid site.
If you deleted the default site example.com(changes are you did some cleanup after adding another site), you may simply want to select the other site you created by setting SITE_ID to 2 for example. If you work with SQL database, look for the django_site table, and locate the site ID you wish to work with.
This way, no need to go into shell and recreating a not necessary desired site.
If you need sites, you can use data fixtures. Read the docs for tip about enabling the sites framework.
I have a django website that I am hosting on twisted via the django WSGIHandler as described here - http://www.clemesha.org/blog/Django-on-Twisted-using-latest-twisted-web-wsgi
All seems OK up to the point where I want to add an extra "site" configuration to my django site using the django Sites framework. Doing so, I add an extra settings.py file for the new site and that seems to work.
What I then want to do is use the twisted NameVirtualHost class to be able to direct one domain (say site1.example.com) to the first settings file, then use another domain (say site2.example.com) to use the second settings file. This works with Apache & mod_wsgi.
The problem I face is that the twisted code can only access one django environment at a time. If I call setup_environ with the first settings file and setup a host for the first domain, a subsequent call to setup_environ will replace the settings file in use so therefore only one set of settings can be used at one time.
Any ideas how to proceed?
Gave up on this in the end. Looks like you cannot easily access 2 Django environments within the same twisted instance. I think it would require multiple instances of twisted with a reverse proxy or some sort of multiprocess hacking - either way its not worth the effort for me so I'm going to try something else...