Hey Gang, I have created a juju charm to deploy multiple django apps to ec2. Currently, I am working on multiple site control and need help with the django_site table.
When am instance is destroyed, the database remains but django is re-installed. The problem arises when old database is kept around and reused with a fresh django install. This new django install has the same settings but the django_site table can get funky. Here is the start of my script to at least set the correct database id, name, and domain. It is hack right here, so I am ask for your thoughts or suggestions. Thank you. NOTE: the regular expressions are simply parsing the settings.py file for site_id and if django.contib.sites is un-commented. site_domain="www.example.com" site_name="example.com" site_id="$(cat $(find . -name 'settings.py') | grep -xv " *#.*" | grep ".*SITE_ID\ *=.*" | sed 's/#.*//g' | sed "s/.*SITE_ID *\= *\(.*\) */\1/g" | sed "s/'//g")" #echo "from django.contrib.sites.models import Site; Site.objects.create(pk=$site_id, domain='here.example.com', name='example.com')" | python manage.py shell # For now, just gonna put in a place holder if the user has listed it in installed_apps sites_used="$(cat $(find . -name 'settings.py') | grep -xv " *#.*" | grep ".*django.contrib.sites.*" | sed 's/#.*//g')" if [ -n "$sites_used" ]; then juju-log "Found django.contrib.sites in installed apps. Creating single table as defined in this script." echo "from django.contrib.sites.models import Site; entry = Site.objects.get(pk=$site_id); entry.objects.all().delete(); Site.objects.create(pk=$site_id, domain='$site_domain', name='$site_name')" | python manage.py shell fi Here are my mysteries: 1) The python manage.py shell comand is giving me this error --> AttributeError: Manager isn't accessible via Site instances 2) How can I retrieve the site_name and site_domain varables with bash scripting for the project. Keep in mind that there can be no user input in the script but I do have all username and passwords available. -- Bust0ut, Surgemcgee: Systems Engineer --- PBDefence.com BudTVNetwork.com RadioWeedShow.com "Bringing entertainment to Unix" -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.