from past 2 days have literally lost patience trying make cloudfiles work project(using cumulus). here of issues:
1.) when upload photo using admin(creating model , registering admin)... photo looks uploaded when try either access using view function photo.objects.all() or going cloudfiles control panel...the image doesnt open up. resource not found. check , double check if region(chicago default me) settings screwing me....but don't think so.
2.) have used collectstatic method collect static files in container , able serve them. infact when click link(say example) - http://ed770b871265201bf471-14f03984d90730040890dd30a2d85248.r68.cf2.rackcdn.com/admin/css/base.css
i able see results , sure u can see too.
but when trying use them static_url in templates - admin pages don't have css working login/home pages being rendered styles.
here settings file/my view functions , important -
static_root = '' static_url = 'http://ed770b871265201bf471-14f03984d90730040890dd30a2d85248.r68.cf2.rackcdn.com/' staticfiles_dirs = ( os.path.join(project_dir,'static'), ) cumulus = { 'username': '***', 'api_key': '****', 'container': 'photos', 'static_container':'static', 'servicenet': false, # whether use rackspace's internal private network 'filter_list': [], 'timeout' : 60 } default_file_storage = 'cumulus.storage.cloudfilesstorage' staticfiles_storage = 'cumulus.storage.cloudfilesstaticstorage' the model file part
class photo(models.model): username = models.foreignkey(user) image = models.imagefield(upload_to='photos') alt_text = models.charfield(max_length=255) admin.site.register(photo)
this view function requested kyle.
def profile_detail(request): if request.user.is_authenticated(): username = request.user.get_username() # userid = user.objects.get(username=username).values('__id') userdetails = user.objects.filter(username=username) photo = photo.objects.get(username=request.user.id) return render_to_response('profile_detail.html',{'userdetails':userdetails,'username':username,'photo':photo}, context_instance=requestcontext(request)) and template profile_detail -
{% extends 'profile.html' %} {% load bootstrap_toolkit %} {% block content %} <img src="{{ photo.image.url }}" alt="{{ photo.alt_text }}" /> <br> <p>{{ user.first_name }}</p> <p>{{ user.last_name }}</p> <p>{{ user.email }}</p> {% endblock %} i checked can view image(no idea how) on hosted site(production) still can't in dev environment.
kyle can please check if testaccount has picture of penguins in 'myprofile' page? :) looking :)
Comments
Post a Comment