Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django, Gunicorn, Nginx, Postgres, Digitial Ocean Server Error 500 on Image Upload
I am developing a website/blog using Django and am in the middle of figuring out the proper setup/settings. I am running Ubuntu Server 16.04 in a virtual machine for testing. I am using what seems to be a common setup with Gunicorn and Nginx as well as PostgreSQL for the database and hosting the static and media files on Digital Ocean Spaces. I intend to host the site on Digital Ocean as well. I have pieced together things from a few different guides here, here, here, and here. I also use Django-Imagekit for handling images (url, resizing, etc) and manage everything in Django Admin. The problem I am facing is that when I upload an image (either directly to an image form or via a post form) and save the object I end up getting a Server Error (500). If I refresh the page it then works fine. This also happens on the site itself (i.e. go to home page, server error, refresh, no error). There are also absolutely no errors in my Gunicorn and Nginx logs. File Structure: site ├── project │ ├── gallery │ │ ├── static │ │ │ ├── gallery │ │ │ │ ├── css … -
How to modify redirect in django middleware
I have a requirement to convert http to https if the redirect happens in django. So I'd like to write a middleware to handle that. I have put the middleware in the top of the middleware list, hope that's correct.I have used the following sample code. But when redirect happens, the url is not the full url, but relative url. So I don't know how to overwrite the url or schema(http or https). I have thought I could replace the http to https in the response, but the content of the response is also empty. So what should I do? class RedirectFilter(object): def process_response(self, request,response): print 1111111111111 print response.status_code print request.path print response.__class__.__name__ if isinstance(response,HttpResponseRedirectBase): print response.url print response.content return response -
null value in column "content_type_id" violates not-null constraint
I'm having difficulty in using django's generic relation and forms. I'm using crispyforms to render my the html. Here's the error that i get. Not sure why it's looking for content_type_id every time i save a record. I tried creating new a new company record using the admin panel and it works. This error only comes out when I use crispy form null value in column "content_type_id" violates not-null constraint Below is my code. Forms.py ` class CompanyFormHelper(FormHelper): form_tag = False render_required_fields = True disable_csrf = True render_required_fields = False layout = Layout( Fieldset( _('Company'), Div(InlineField('name'), css_class='col-sm-12'), Div(InlineField('email'), css_class='col-sm-12'), Div(InlineField('phone'), css_class='col-xs-6'), Div(InlineField('type'), css_class='col-xs-6'), Div(InlineField('is_partner'), css_class='col-xs-6'), Div(InlineField('is_company'), css_class='col-xs-6'), Row( Formset('company_location_form', 'company_location_form_helper'), ), Submit('submit','Submit'), ), ) class CompanyForm(ModelFormBase): def __init__(self,*args,**kwargs): super().__init__(*args,**kwargs) self.helper = CompanyFormHelper() class Meta: model = Company fields = ('name','email','phone','type','is_partner','is_company') widgets = {} class CompanyLocationFormsHelper(FormHelper): form_tag = False disable_csrf = True layout = Layout( Fieldset( _('Company Address'), Div(InlineField('line_first'), css_class='col-sm-12'), Div(InlineField('line_second'), css_class='col-sm-12'), Div(InlineField('city'), css_class='col-xs-6'), Div(InlineField('province'), css_class='col-xs-6'), Div(InlineField('postal_code'), css_class='col-xs-6'), Div(InlineField('country'), css_class='col-xs-6'), ), ) # template = 'is_portal/core/crispy_form/table_inline_formset.html' render_required_fields = True class CompanyLocationForm(ModelFormBase): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.helper = CompanyLocationFormsHelper() class Meta: model = Address fields = ('line_first','line_second','city','province','postal_code','country') widgets = { 'line_first': forms.TextInput(attrs={'required':'required'}), 'city': forms.TextInput(attrs={'required':'required'}), 'country': forms.Select(attrs={'class':'select required'}), } CompanyLocationFormset = … -
Django file-size chaos (in finder and compressed folder)
I went to zip up a Django project to send it when I noticed that the project was over 600 MB. I think the sqlite3 database file was over 450mb, so I went through some steps to reset it and deleted the profiler app that was generating all that data. However, when I inspect he root folder I still see around a ~400 mb file size for the whole project. Here is my finder output for ls -lha (which seems pretty ridiculous in itself?) App: drwxr-xr-x 14 funglr-dan staff 448B Feb 13 11:03 django_app What?? 448 bytes? Clearly not right. Inside the App: drwxr-xr-x 13 funglr-dan staff 416B Feb 13 11:04 .git -rw-r--r-- 1 funglr-dan staff 500B Feb 13 11:03 .gitignore drwxr-xr-x 3 funglr-dan staff 96B Jan 15 20:49 .vscode drwxr-xr-x 26 funglr-dan staff 832B Feb 7 16:30 bin -rw-r--r-- 1 funglr-dan staff 97B Jan 15 20:49 date-test.py drwxr-xr-x 3 funglr-dan staff 96B Feb 7 16:30 include drwxr-xr-x 3 funglr-dan staff 96B Jan 11 18:44 lib -rw-r--r-- 1 funglr-dan staff 60B Feb 13 10:26 pip-selfcheck.json drwxr-xr-x 3 funglr-dan staff 96B Jan 30 18:31 selenium drwxr-xr-x 9 funglr-dan staff 288B Feb 13 10:56 webapp Yet, when I inspect that very same … -
Loggin below WARNING level is not working in django
With this setting LOGGING = { 'version': 1, 'disable_existing_loggers': True, 'root': { 'level': 'WARNING', 'handlers': ['sentry', 'console', 'file'], }, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s ' '%(process)d %(thread)d %(message)s' }, }, 'handlers': { 'sentry': { 'level': 'WARNING', # To capture more than ERROR, change to WARNING, INFO, etc. 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', 'tags': {'custom-tag': 'x'}, }, 'file': { 'level': 'INFO', 'class': 'logging.FileHandler', 'filename': os.path.join(BASE_DIR, 'logs/web.log'), }, 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'verbose' }, }, 'loggers': { 'all': { 'handlers': ['console'], 'level': 'DEBUG', }, 'app': { 'handlers': ['file'], 'level': 'INFO', }, 'warnings': { 'handlers': ['sentry'], 'level': 'WARNING', }, } } I expect that All logs will appear in console Logs from INFO to CRIT will appear both in console and output file Logs from WARNING to CRIT to be streamed to sentry But in fact I have only WARNING-CRIT logs in all three destinations. Where I am wrong? -
Django: use TIME_ZONE='Asia/Seoul', USE_TZ=False but time stored in database is wrong?
This is my settings for time zone: TIME_ZONE = 'Asia/Seoul' USE_TZ = False The reason that I set USE_TZ as False is that since my program has a lot of codes comparing model's created DateTime field with other dates, so I want to apply my TIME_ZONE=Asia/Seoul in all fields of model so that make these comparison easier. Let say I created a model like below: (The time of Seoul is 2018-02-13 10:10:29, which is 2018-02-13 1:10:29 in UTC) >> s = Symbol.objects.get(code="123456", name="aa") >> s.created datetime.datetime(2018, 2, 13, 10, 10, 29, 771952) which shows Seoul time exactly. But when I checked it in database(PostgreSQL), of which timezone is set as KST (or ROK, Republic of Korea), created field shows like this: 2018-02-13 10:10:29.771952+09 which looks strange because it adds "+09" on the actual Korean created time! I want to know what's wrong with my setting or interpretation. Need your advices. Thanks -
Django Post request not receiving data
I've spent hours looking up this issue with no avail. I am having issue with post data from an html page I am sending {'username': 'username'} but when I do request.POST.get('username') it returns none, I alos tried {username, 'username'} def test_post(request): if request.method == 'POST': print(request.POST.get('username')) return HttpResponse("Good!") else: return HttpResponse("Bad.") Console Development Server None <<<< [12/Feb/2018 19:39:53] "POST /test_post HTTP/1.1" 200 5 (edited) I am sending the data as {'username': 'username'} That works correctly how come I am unable to get it to show up? This is the Javascript code that calls from the page: document.getElementById('submit').addEventListener('click', function(e) { e.preventDefault(); var username = document.getElementById("username").value; data = {gitusername: username}; console.log(data); var request = new XMLHttpRequest(); request.open('POST', '/getuser', true); request.setRequestHeader('Content-Type', 'x-www-form-urlencoded'); request.send(data); }); -
Django's generic CreateView leading to a 404
I'm reading the documentation on Django's generic editing views and trying to follow them with a simple example. I have a project my_project with an app my_app with the following structure: . ├── __init__.py ├── admin.py ├── apps.py ├── forms.py ├── models.py ├── templates │ └── my_app │ ├── author_form.html │ └── contact.html ├── tests.py ├── urls.py └── views.py The urls.py is from django.urls import path from .views import ContactView, AuthorCreate urlpatterns = [ path('create/', AuthorCreate.as_view()) ] and the project-level urls.py is from django.contrib import admin from django.urls import path, include urlpatterns = [ path('admin/', admin.site.urls), path('my_app/', include('my_app.urls')) ] The views.py is from django.views.generic.edit import FormView, CreateView from my_app.models import Author class AuthorCreate(CreateView): model = Author fields = ['name'] Note that I have not implemented the get_absolute_url method in the example, because it is unclear to me how the 'author-detail' named URL should be defined. The problem is, however, that after entering a name and pressing the "Create" button, I get a 404 error: Page not found (404) Request Method: GET Request URL: http://localhost:8000/my_app/create/None Using the URLconf defined in my_project.urls, Django tried these URL patterns, in this order: admin/ my_app/ contact/ [name='contact'] my_app/ create/ The current path, my_app/create/None, didn't match … -
With django cookie cutter, how to change to a the custom user model mid-project
I am trying to use Cookiecutter to help me to deploy a web app with Heroku and Amazon S3. This is an app that I developed locally without Cookiecutter so I am copy-pasting the files into the new project and debug step by step. The original app used the build-in Django User Model so I would like to switch to the Abstract User Model that comes with Cookiecutter. I started to create a new database for this project to start from scratch. Then I thought it would be as simple as replacing User by AUTH_USER_MODEL models.py from config.settings.base import AUTH_USER_MODEL class Category(models.Model): name = models.CharField(max_length=30) description = models.CharField(max_length=140,blank=True,null=True) date_created = models.DateField(default=timezone.now) date_updated = models.DateField(auto_now=True) created_by = models.ForeignKey(AUTH_USER_MODEL, related_name="categories") def __str__(self): return self.name I get this error when running manage.py migrate accounts.User.user_ptr: (fields.E301) Field defines a relation with the model 'auth.User', which has been swapped out. HINT: Update the relation to point at 'settings.AUTH_USER_MODEL' In settings.py AUTH_USER_MODEL = 'users.User' Where I am missing something ? -
Catch all exceptions in django rest framework
I guess this is more of a code quality question but it does involve handling unhandled exceptions is Django rest framework. Deleting a protected record just return <h1>500 internal server error<h1> So I added the example custom exception handler. The first line returns a response that is none. response = exception_handler(exc, context) from rest_framework.views import exception_handler from rest_framework.response import Response from rest_framework import status def custom_exception_handler(exc, context): response = exception_handler(exc, context) if response is None: #DRF could not process the exception so we will treat it as a 500 and try to get the user as much info as possible. response = Response({'error': str(exc)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) return response So in this case I am treating it as a 500 because the DRF couldn't handle the exc. I guess my question is is this an appropriate way to handle it and does anyone have experience with this have a better solution? -
django Built-in template tags and filter Cut command not removing second space
My database stored phone numbers as "(123) 456-7890 " I need to remove all the spaces from a phone number so that I can make calls via Cisco phone. <td><a href="ciscotel:1{{contact.Phone|cut:" "}}" target="_self">{{ contact.Phone | cut:" "}} But django is displaying html as: (123)456-7890 I tried : {{contact.Phone|cut:"("|cut:")"|cut:"-"|cut:" "}} and {{contact.Phone|cut:"("|cut:" "|cut:"&nbsp;"}} The documentation makes it seem like one cut function should clear both spaces. Thanks -
Parsing Javascript values to Django views
I am new to Django and I am just trying to figure it out and I did posted it in official Django google group but no answer. I am working with Google Map API in my Django template for GeoLocation and I intend to populate DB table dynamically after extracting information from JavaScript in my Django template. Following is the code: var map, infoWindow; function initMap() { map = new google.maps.Map(document.getElementById('map'), { center: {lat: -34.397, lng: 150.644}, zoom: 6 }); infoWindow = new google.maps.InfoWindow; // Try HTML5 geolocation. if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var pos = { lat: position.coords.latitude, lng: position.coords.longitude }; infoWindow.setPosition(pos); infoWindow.setContent('Location found.'); infoWindow.open(map); map.setCenter(pos); }, function() { handleLocationError(true, infoWindow, map.getCenter()); }); } else { // Browser doesn't support Geolocation handleLocationError(false, infoWindow, map.getCenter()); } } function handleLocationError(browserHasGeolocation, infoWindow, pos) { infoWindow.setPosition(pos); infoWindow.setContent(browserHasGeolocation ? 'Error: The Geolocation service failed.' : 'Error: Your browser doesn\'t support geolocation.'); infoWindow.open(map); } I need to save longitude and latitude with GeoLocation Info about the location in human readable format in my model. My Model is class Address(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL, models.CASCADE) latitude = models.CharField(max_length=10) longitude = models.CharField(max_length=10) address = models.CharField(max_length=100) ..... My form is: class UserAddressForm(forms.ModelForm): class Meta: model = Address fields = … -
In Django admin how can i hide or remove the Pencil, "+" and "x"?
I can hide all the options in the model base, but is not necessary, on the relation i can't do that i think that exist a simple form (not with css) to remove or hide it thanks **********These are********** -
Django-import-export get file name
I've been scouring the docs and internet for a couple days now trying to figure out how I can capture the imported filename from Django import export admin panel's import feature. Basically, I want to save this filename to ensure that future file uploads are not the same. the process being: 1. Someone imports a file picture of admin panel with import button 2. The filename is stored admin panel, import file section 3. If someone tries to upload same file again, error error in file import But I can't figure out how to get that filename from Django import export. Help is much appreciated. -
Django REST: Uploading and serializing multiple images
I have 2 models Task and TaskImage which is a collection of images belonging to Task object. What I want is to be able to add multiple images to my Task object, but I can only do it using 2 models. Currently, when I add images, it doesn't let me upload them and save new objects. settings.py MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' serializers.py class TaskImageSerializer(serializers.ModelSerializer): class Meta: model = TaskImage fields = ('image',) class TaskSerializer(serializers.HyperlinkedModelSerializer): user = serializers.ReadOnlyField(source='user.username') images = TaskImageSerializer(source='image_set', many=True, read_only=True) class Meta: model = Task fields = '__all__' def create(self, validated_data): images_data = validated_data.pop('images') task = Task.objects.create(**validated_data) for image_data in images_data: TaskImage.objects.create(task=task, **image_data) return task models.py class Task(models.Model): title = models.CharField(max_length=100, blank=False) user = models.ForeignKey(User) def save(self, *args, **kwargs): super(Task, self).save(*args, **kwargs) class TaskImage(models.Model): task = models.ForeignKey(Task, on_delete=models.CASCADE) image = models.FileField(blank=True) However, when I do a post request: I get the following traceback: File "/Applications/Anaconda/anaconda/envs/godo/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner 41. response = get_response(request) File "/Applications/Anaconda/anaconda/envs/godo/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) File "/Applications/Anaconda/anaconda/envs/godo/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/Applications/Anaconda/anaconda/envs/godo/lib/python3.6/site-packages/django/views/decorators/csrf.py" in wrapped_view 58. return view_func(*args, **kwargs) File "/Applications/Anaconda/anaconda/envs/godo/lib/python3.6/site-packages/rest_framework/viewsets.py" in view 95. return self.dispatch(request, *args, **kwargs) File "/Applications/Anaconda/anaconda/envs/godo/lib/python3.6/site-packages/rest_framework/views.py" in dispatch 494. response = self.handle_exception(exc) … -
from django.contrib.auth.models import User
I know that this question had been asked and answered already, but the solutions I saw so far are not solving the problem. I am trying to run the following command in python to authenticate users who log in a website I am currently building. 'from django.contrib.auth.models import User' However, I am getting the following error: 'Traceback (most recent call last): "C:\Users\<user>\Documents\GitHub\MegaPortal\BackEnd\BackEnd\test.py", line 4, in <module> from django.contrib.auth.models import User File "C:\Users\<user>\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\models.py", line 2, in <module> from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "C:\Users\<user>\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module> class AbstractBaseUser(models.Model): File "C:\Users\<user>\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\db\models\base.py", line 100, in __new__ app_config = apps.get_containing_app_config(module) File "C:\Users\<user>\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 244, in get_containing_app_config self.check_apps_ready() File "C:\Users\<user>\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 127, in check_apps_ready raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.' What is weird is that this command gives an error when I run on atom, but when I run using Django's shell, it does not give any error. I have already tried putting in my settings.py file the following command import django django.setup() but still nothing. Any help is highly appreciated. -
Dango Admin bracket highlighter
I've seeking solution for simple bracket highlighter(like match_brackets option in Sublime Text) for django-admin fields. After checking ckeditor and tinymce I came to conclusion that they are not that solution what I am looking for. -
Create intermediate model object, by connect patient, treatment, disease, and symptom objects
I am creating a medical app and I have a intermediate model that I use the connect that patient, treatment, disease, and symptom objects. Problem : After the set of all patient, treatment, disease, and symptom objects have been created, I cannot connect them to create the consultation object in the appropriate order. Using the shell I was able to connect them u1 = User.objects.create(email='qeng@gmail.com') p1 = Patient.objects.create(NIS='I902456',first_name='Andre',last_name='iivri', contact='908-2456',born='1991-02-15',gender='Male',email_address='dlt@gmail.com', location='Quey',user=u1) p1.save() c1 = Consultation.objects.create() p1.consultation_set.add(c1) s1 = Symptom.objects.create(identity='id',description='des') s1.consultation_set.add(c1) d1 = Disease.objects.create(identity='id', description='desc') d1.consultation_set.add(c1) When I attempt to replicate this with each view in my views.py document I just keep creating a new consultation object which is not what I want to do. This is the code views.py ++++++++++ Imports from script.models import Treatment, Symptom, Disease, Consultation, Patient from django.shortcuts import render, redirect from django.views.generic import CreateView, ListView, DetailView, TemplateView from script.forms import IdentityForm, ConditionForm, DiseaseForm, TreatmentForm Create Patient view class IdentityCreate(CreateView): template_ = 'script/patient_form.html' def get(self, request): document = IdentityForm() patient = Patient.objects.filter(user = request.user) context = {'form':document, 'patient':patient} return render(request, self.template_, context) def post(self, request): document = IdentityForm(request.POST) patient_medical_id = None if document.is_valid(): patient_document_authentication = document.save(commit=False) patient_document_authentication.user = request.user patient_document_authentication.save() # Creates consultation object patient_consult = Consultation.objects.create() #Add … -
passing value to get_context_data from Django template
I am working on a Django template associated with a particular model. Within the view for this template, I am trying to access a record from a different model (Terms containing scientific terms), based on the parameter I would pass in the template. I tried being using get_context_data to query a random term in the database, and then use a custom filter tag to replace the term to the one I want from within the template. Django is smarter, though and wouldn't let me do that. Currently, I am trying to define the context within my views.py class ArticlesView(DetailView): model = models.Articles template_name = 'web/articles-details.html' context_object_name = 'Articles_details' def get_context_data(self, *args, **kwargs): ctx = super(ArticlesView, self).get_context_data(*args, **kwargs) ctx['featured']=Articles.objects.filter(featured=True) ctx['term','arg']=Articles.objects.filter('slug'=='arg') return ctx In the above code, the 'featured' context works fine, but not the 'term' one. It is clearly wrong; I know that... but I can't figure out what the correct syntax would be, and how I would provide the parameter from within the template. (I am trying to print out just the slug of the 'scientific term' in this example). Any thoughts? I know that I can set a ForeignKey within my models to connect them. The problem with that … -
How to store social usernames/links in Django?
I have a personal blog written with Django. I want to make my social links/usernames dynamic so I can change them whenever I want. I'm doing this with charfields. I'm adding new charfield for each social username/link field then my template's getting these usernames to show them in a tags. It's okay but I think it's not the easiest way. Am I wrong or there is a better way to do this? -
Can't initialise GIT SCM on Mac OS High Sierra.
I am a complete novice in programming. Please don't make fun of me. I am trying to learn programming in Django. I wish to use GIT SCM to manage version control of my project. I seem to have succeeded in installing GIT SCM but I am not being able to initialise it and move forward. Could someone please help me ? Below you can find the error message thrown at me by the terminal. MacBook Pro (13 inch, early 2011) MacOS High Sierra (version 10.13.3) $ git init xcrun: error: active developer path ("/Applications/Xcode-beta.app/Contents/Developer") does not exist Usesudo xcode-select --switch path/to/Xcode.appto specify the Xcode that you wish to use for command line developer tools, or usexcode-select --installto install the standalone command line developer tools. Seeman xcode-selectfor more details. -
Django cannot import name _imaging
I'm trying to deploy a Django application, however, during deployment, I'm getting the following error: Apache Error Logs: https://pastebin.com/3MzEkaws Any help would be greatly appreciated. -
Django CreateView with AJAX
I want to create, update and delete objects through generic views and modals using AJAX in Django. The official documentation of Django talk about AjaxableResponseMixin and show this code: from django.http import JsonResponse from django.views.generic.edit import CreateView from myapp.models import Author class AjaxableResponseMixin: """ Mixin to add AJAX support to a form. Must be used with an object-based FormView (e.g. CreateView) """ def form_invalid(self, form): response = super().form_invalid(form) if self.request.is_ajax(): return JsonResponse(form.errors, status=400) else: return response def form_valid(self, form): # We make sure to call the parent's form_valid() method because # it might do some processing (in the case of CreateView, it will # call form.save() for example). response = super().form_valid(form) if self.request.is_ajax(): data = { 'pk': self.object.pk, } return JsonResponse(data) else: return response class AuthorCreate(AjaxableResponseMixin, CreateView): model = Author fields = ['name'] (I have a model which looks like this) However I don't understand how to implement it in a modal. I do have this form that I'm currently using but it's a web page, not a modal: <form method="post" novalidate> {% csrf_token %} {% include 'includes/form.html' %} <button type="submit" class="btn btn-success">AJouter</button> </form> Is there a simple way to implement it in a modal using some ajax and jquery? -
Django model formsets saving object creator error: "null value in column "creator_id" violates not-null constraint"
When I try to save model formset and another related form in my view, i get the mentioned error. I now that it is because of I don't save user to the Ad model before saving it, but it seems I do that in my code... Anyways I guess the saving might be even different since my user's id is inherited from default django User model. views.py Ad model in models.py Image model in models.py Both forms i try to save The error I'm getting -
Jquery function not working properly in my Django template
I am trying to show all courses in a faculty when clicked on faculty name and that is working properly. But also, I was trying to show all the courses from a specific department. Now, I managed to show the courses in a department also, but courses from faculties or previous accessed departments won't go hidden and all will show one under another. Problem is, I don't know how to fix my function. I hope I am also rendering it right. http://pasted.co/b1babe18