Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
How to create a Django formset with three or more related items?
class Revenue(models.Model): sale_of_place = models.DecimalField(_('Продажа магазина'), max_digits=8, decimal_places=2) income_statement = models.ForeignKey(IncomeStatementOfProfitOrLoss, null=True, blank=True) published_date = models.DateTimeField(_('дата публикации'), auto_now_add = True, blank=True, null=True) class CostOfSale(models.Model): server = models.DecimalField(_('Сервер'), max_digits=8, decimal_places=2) managers_bonus = models.DecimalField(_('Бонусы менеджера'), max_digits=8, decimal_places=2) team_lead = models.DecimalField(_('Тим лид - Саша'), max_digits=8, decimal_places=2) tech_dir = models.DecimalField(_('Тех дир - Мурат'), max_digits=8, decimal_places=2) frontend_dev = models.DecimalField(_('Фронт енд - Аслан'), max_digits=8, decimal_places=2) interns = models.DecimalField(_('Стажеры'), max_digits=8, decimal_places=2) income_statement = models.ForeignKey(IncomeStatementOfProfitOrLoss, null=True, blank=True) published_date = models.DateTimeField(_('дата публикации'), auto_now_add = True, blank=True, null=True) class GeneralAndAdministrativeExpenses(models.Model): taxes = models.DecimalField(_('Налоги'), max_digits=8, decimal_places=2) accounter_salary = models.DecimalField(_('Зарплата бухгалтера'), max_digits=8, decimal_places=2) rent = models.DecimalField(_('Аренда'), max_digits=8, decimal_places=2) bank_commission = models.DecimalField(_('Виза - мастер кард'), max_digits=8, decimal_places=2) office_maintenance = models.DecimalField(_('Офисные принадлежности'), max_digits=8, decimal_places=2) designer_salary = models.DecimalField(_('Дизайнер - Бахтияр'), max_digits=8, decimal_places=2) income_statement = models.ForeignKey(IncomeStatementOfProfitOrLoss, null=True, blank=True) published_date = models.DateTimeField(_('дата публикации'), auto_now_add = True, blank=True, null=True) -
How to save django log file in s3 bucket of a django app hosted in aws elastic beanstalk
I've a Django application hosted in Docker elastic beanstalk. I need to save the django log file in the s3 bucket. We can retrieve the instance logs using the AWS console or using "eb logs" command. But to retrieve the django logs we'he to manually ssh to the eb instance and check it. If we enable the log rotation in eb configuration we can save the instance logs in the s3 bucket. But is there any similar ways to save django log inside the eb instance docker container to the s3 bucket. -
Django contrib admin default admin and password
This may be a silly question. I start a new Django project as Document says, which only included an admin page. I start the server and use a web browser accessing the page. What can I enter in the username and password? Is their any place for me to config the default admin account? -
Django: no such table snippets_snippet
I'm following this Django Rest tutorial on serialization: http://www.django-rest-framework.org/tutorial/1-serialization/#getting-started I followed it pretty much to the letter. It gives the above error when I try to save a snippet. from snippets.models import Snippet from snippets.serializers import SnippetSerializer from rest_framework.renderers import JSONRenderer from rest_framework.parsers import JSONParser snippet = Snippet(code='foo = "bar"\n') snippet.save() I'm working on Windows. The tutorial is made for Apple. I have had to enter some commands slightly differently for this reason. I have no idea if this has to do with what is wrong in this case. I don't know where to even start in figuring out the problem here, so I could use any help. Thanks. -
django two apps with same urls in each url's.py file
I have two apps in my django project one is "home" and other is "administrator". I am using home app for frontend of the site and administrator app for admin panel and the urls' for accessing both frontend and admin panel respectively are :- www.domainname.com/home www.domainname.com/administrator main urls.py file is :- from django.conf.urls import include, url from django.contrib import admin urlpatterns = [ url(r'^home/', include('home.urls')), url(r'^administrator/', include('administrator.urls')) ] Home's urls.py file is :- from django.conf.urls import url from . import views urlpatterns = [ url(r'^$', views.index, name='index'), url(r'^sport$', views.sport, name='sport'), url(r'^register$', views.signup_signin, name='register'), url(r'^login$', views.login, name='login'), url(r'^signup$', views.signup, name='signup'), url(r'^registered-successfully$', views.registered_successfully, name='registered-successfully'), url(r'^logout$', views.logout_view, name='logout'), url(r'^dashboard$', views.dashboard, name='dashboard'), url(r'^create-new-event$', views.create_new_event, name='create-new-event'), url(r'^help$', views.help, name='help'), url(r'^account-settings$', views.account_settings, name='account-settings') ] Admin's urls.py file is :- from django.conf.urls import url from . import views urlpatterns = [ url(r'^$', views.index, name='index'), url(r'^logout$', views.logout, name='logout'), url(r'^dashboard$', views.dashboard, name='dashboard'), url(r'^profile$', views.profile, name='profile'), url(r'^edit-profile$', views.edit_profile, name='edit-profile'), url(r'^check-password$', views.check_password, name='check-password'), url(r'^help$', views.faq_management, name='help') ] As you can check that there are some common url's in both app's file, like index, dashboard, logout help. These urls are creating problem if i link them in href, for example if i link "help" url in frontend using <a href="{% url 'help' … -
Why is CSS specific element not changing in Django deployment?
My CSS files are loaded correctly. However, I added an id to a form and an input inside the form. I targeted those IDs in the css file and it works in production. Whenever I transfer the files to the deployed server, the form field doesn't show any changes. HTML <form id="search_form" class="navbar-form navbar-left" method="GET" action="/search/"> <div class="form-group"> <input type="text" id="search_box" class="form-control" name="search" placeholder="Search" value="{% block srch_val %}{% endblock %}"> </div> <button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button> </form> CSS #search_form { position: absolute; padding-left: 200px; } #search_box { width: 500px; } I have deleted the whole project from the server and reuploaded it. I ran collectstatic without any error. All the other CSS works except these two. What could be the reason? -
Having conflict with Django URL and Angular Route
I am currently working on a project using Django and Angular. I am trying to implement Django's Password-Reset app, which seems pretty easy to set up. I followed the instructions and I ran into a peculiar issue that is caused by Angular's routing. I am trying to link to a FormView using <a href="{% url 'password_reset_recover' %}">Forgot password?</a> But it seems that Angular's routing keeps picking up the literal translation of the link http://127.0.0.1:8000/%7B%%20url%20'password_reset_recover'%20%%7D This of course causes a routing error to pop up. Is there anyway I can link to this view without Angular interfering? -
How to ask for headers in django rest framework browsable api
How can I ask for headers in django rest framework browsable api view, I am authenticating calls by matching a token and that is passed in headers. I can use that API in the postman and It's working great, but I want to give inputs for putting access token on the browsable api of django rest framework. For reference like where I want the inputs for headers, I'm attaching a picture of the UI. Any help is appreciated. Thanks -
How to assign search views to haystack+whoosh in django?
I am trying to implement full text search functionality in my site. I wanted to use Haystack with Whoosh as the backend. I watched Mike Hibbert's Tutorial on the same. Everything works fine except, probably the views. I am confused if I should declare the url for search or not. Likewise, I'm also not getting how Haystack uses templates. Here's my url: url(r'^search/',include('haystack.urls')), My view is as below: def search(request): results = SearchQuerySet().autocomplete(content_auto=request.GET.get('query','')) return render(request,"question/ajax_search.html",locals()) ajax_search.html {% if results %} {% for res in results %} <li style="margin-top: 5px;list-style-type:none;"> <a href="{{ res.object.get_absolute_url }}">{{ res.object.title }}</a> </li> {% endfor %} {% else %} <p style="margin-left:12px"> Sorry, no result for <b>{{ query }}. </b><a id="ask_now" name="ask_now" href='{% url "ask" %}'>Ask</a> now! </p> {% endif %} Now, when I search in my site, only the else part of ajax_search.html shows up. Help me out where I'm going wrong. -
Stop Django from serving during startup error
I have setup my Django/Tastypie app with uwsgi. If I specify a incorrect DB name and start the app using python manage.py runserver it throws an error ( coz the DB is incorrect ) However if I restart the uwsgi service it does not show any errors and continues to serve requests ( which eventually fail ) user@ip-172-31-24-106:~/workspace/LCAPI/DjangoTastypie$ sudo service uwsgi restart uwsgi stop/waiting uwsgi start/running, process 20781 user@ip-172-31-24-106:~/workspace/LCAPI/DjangoTastypie$ tail -f logs/djangotastytreat.log added /usr/local/lib/python2.7/dist-packages/ to pythonpath. added /usr/lib/python2.7/ to pythonpath. WSGI app 0 (mountpoint='') ready in 1 seconds on interpreter 0xa323e0 pid: 20782 (default app) *** uWSGI is running in multiple interpreter mode *** spawned uWSGI master process (pid: 20782) spawned uWSGI worker 1 (pid: 20786, cores: 1) spawned uWSGI worker 2 (pid: 20787, cores: 1) spawned uWSGI worker 3 (pid: 20788, cores: 1) spawned uWSGI worker 4 (pid: 20789, cores: 1) spawned uWSGI worker 5 (pid: 20790, cores: 1) How can i setup uwsgi to stop serving if the Django app failed as well -
Django data to Google Charts
View: def home(request, template = 'home.html'): if request.user.is_authenticated(): username = request.user.username loan = request.user.loan.filter(loan_id = 1) tCount = Transaction.objects.filter(loans = loan).count() positiveT = serializers.serialize('json', Transaction.objects.filter(loans = loan, amount__gte = 0), fields=('amount',)) negativeT = serializers.serialize('json', Transaction.objects.filter(loans = loan, amount__lte = 0), fields=('amount',)) context = { 'username' : username, 'loan' : loan, 'tCount': tCount, 'positiveT' : positiveT, 'negativeT' : negativeT, } return render( request, template, context) Template: <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> google.charts.load('current', {packages: ['corechart', 'bar']}); google.charts.setOnLoadCallback(drawVisualization); function drawVisualization() { var data = "{{ chartData }}" var un = "{{username}}'s chart"; var negativeT = {{ negativeT | safe }} var positiveT = {{ positiveT | safe }} //var rows = "{{ tCount }}" var data = new google.visualization.DataTable(); data.addColumn('string', 'Month'); data.addColumn('number'); data.addColumn('number'); data.addRows(12); data.setCell(0, 0, 'January'); data.setCell(1, 0, 'February'); data.setCell(2, 0, 'March'); data.setCell(3, 0, 'April'); data.setCell(4, 0, 'May'); data.setCell(5, 0, 'June'); data.setCell(6, 0, 'July'); data.setCell(7, 0, 'August'); data.setCell(8, 0, 'September'); data.setCell(9, 0, 'October'); data.setCell(10, 0, 'November'); data.setCell(11, 0, 'December'); data.setCell(0, 1, positiveT[0]); data.setCell(1, 1, 18); data.setCell(2, 1, 20); /** data.setCell(3, 1, 19); data.setCell(4, 1, 18); data.setCell(5, 1, 20); data.setCell(6, 1, 19); data.setCell(7, 1, 18); data.setCell(8, 1, 20); data.setCell(9, 1, 19); data.setCell(10, 1, 18); data.setCell(11, 1, 20); */ data.setCell(0, 2, negativeT[0]); data.setCell(1, 2, … -
django 24 hour countdown with moment.js countdown.js
I am using django 1.10 and python 2.7. I have a date-time that I am trying to get a 24 hour countdown to display from. I am using moment and countdown in a template to display the 24 hour countdown. The issue I have is that sometimes the count down is displayed as 24 hours and sometimes displayed as 12 hours. When I enter the date-time as a.m, the correct 24 hour count down is displayed, but when I enter the date-time as p.m, the count down is displayed as 12 hours. Here is an example: When I enter the date as Sept. 26, 2016, 8:50 a.m, the correct 24 hour count down is displayed. However, when I enter a date as Sept. 26, 2016, 8:50 p.m, the count down is changed to 12 hours. The count down should also be 24 hours. Here is my code: $(document).ready(function() { var utcTimestamp = moment.tz('{{ latest_document_saved_metadata_date|date:"c" }}', 'UTC'); var localTimestamp = utcTimestamp.tz(moment.tz.guess()); $('.header_countdown').countdown(localTimestamp.format("YYYY-MM-DD h:mm:ss"), function(event) { $(this).html(event.strftime('%H:%M:%S' + ' hours')); }); }); I have read the django docs, in particular the date format docs, but I am stumped on this issue. I would be grateful for any suggestions. -
Queryset filter with three-deep nested models (multiple one-to-many relationships)
I'm trying to figure out how to filter some queries in Django with my models setup something like this: class CarCompany(models.Model): name = models.CharField() class CarModel(models.Model): name = models.CharField() company = models.ForeignKey(CarCompany) class ModelYear(models.Model): description = models.CharField() carmodel = models.ForeignKey(Model) company = models.ForeignKey(CarCompany) first_availability = models.DateField() last_availability = models.DateField(blank=True, null=True) I'd like to be able to check which CarCompany objects have CarModel objects that don't have any active ModelYear objects (active being either a last_availability date in the future, or a blank/null last_availability). I'm having trouble figure out how to transverse the relationships since each next layer can have multiple objects. It would be especially handy if I could combine CarModel and ModelYear, but it won't work design wise for this. Any thoughts as to how I can sort this out? -
Django Rest Framework query related fields
I have the following two models: I am looking to query my places model and return all locations where "place_category" = type I'm not sure how I would go about, or if it is possible to traverse backwards and return all locations that have the place category relationship. class PlaceCategory(models.Model): type = models.CharField(max_length=128) def __unicode__(self): return self.type class Location(models.Model): name = models.CharField(max_length=200) address = models.ForeignKey(Address, null=True, blank=True) latitude = models.DecimalField(max_digits=12, decimal_places=9, null=True, blank=True) longitude = models.DecimalField(max_digits=12, decimal_places=9, null=True, blank=True) place_category = models.ForeignKey(PlaceCategory, null=True, blank=True) def __unicode__(self): return unicode(self.name) Here are my serializers: class PlaceCategorySerializer(serializers.HyperlinkedModelSerializer): class Meta: model = PlaceCategory fields = ("type",) class LocationSerializer(serializers.HyperlinkedModelSerializer): class Meta: depth = 2 model = Location address = AddressSerializer place_category = PlaceCategorySerializer map_features = MapFeaturesSerializer images = RelatedImagesSerializer fields = ("name", "neighborhood", "address", "latitude", "longitude", "place_category", "map_features", "images",) My views: class PlaceCategoryViewSet(viewsets.ModelViewSet): queryset = PlaceCategory.objects.all() serializer_class = PlaceCategorySerializer def get_queryset(self): queryset = PlaceCategory.objects.all() place = self.request.query_params.get('place', None) if place is not None: queryset = queryset.filter(type=place) return queryset class LocationViewSet(viewsets.ModelViewSet): queryset = Location.objects.all() serializer_class = LocationSerializer -
UnboundLocalError- local variable 'term_list' referenced before assignment
In my Django view I am building a tuple I want to read in my template my tuple name is term_list and I append to it inside for loop def lease_payment_details(request, pk): lease_id = pk if lease_id: try: lease = get_object_or_404(Lease, pk=lease_id) try: activeterm = LeaseTerm.objects.get(lease=lease) start = activeterm.start_period.order_value end = activeterm.end_period.order_value period_list = Period.objects.filter(order_value__lte = start, order_value__gte = end) total = 1000 for obj in period_list: obj.discount = 0 obj.amount = activeterm.amount obj.topay = total - obj.amount - obj.discount term_list.append(obj) payment = activeterm.leasepayment_set.all().order_by('payment_date') except LeaseTerm.DoesNotExist: activeterm = None payment = None except ValueError: raise Http404get_object_or_404(Lease, pk=lease_id) else: lease = "None" activeterm = "None" payment = "None" term_list = "None" data = { 'lease': lease, 'payment': payment, 'activeterm':activeterm,'term_list':term_list, } return render(request, 'lease/lease_payment_details.html', {'data': data}) but I am getting this error local variable 'term_list' referenced before assignment What I am doing wrong? -
Inserting data into a Django DB
I'm trying to use a regular python script to add data to a table that was created via the standard django process (start project/app/create model etc). In the same DB, I set up another table with the same columns as the django DB to test on, and wrote a script that successfully parsed data and inserted it into that DB. When I changed the table name so that the data would be written to the standard Django table, nothing was inserted and no error was thrown. Is there something that prevents access to the Django tables that I'm unaware of? -
Django: How do I use a foreign key field in aggregation?
Let's say I have the following two models: class Parent(models.Model): factor = models.DecimalField(...) ... other fields class Child(models.Model): field_a = models.DecimalField(...) field_b = models.DecimalField(...) parent = models.ForeignKey(Parent) ... other fields Now I want to calculate the sum of (field_a * field_b * factor) of all objects in the Child model. I can calculate the sum of (field_a * field_b) with aggregate(value=Sum(F('field_a')*F('field_b'), output_field=DecimalField())). My question is how I can pull out the factor field from the Parent model? I am new to Django and I really appreciate your help! -
How can i initialize String in python
I want to initialize a String variable in python as follow: { "error":0, "response":"success" } Please provide me the valid syntax -
Django, Apache, failure with Debug=False
I have a problem with Django, running on Apache and Python 3.5. App is running okay, and the first problem with my app is with Debug=False thing. I already created custom handler404 method , and when i type some wrong URL, basically I'm expecting Django on request to show me my custom 404 template, but he don't do that! Django constantly showing his message: *You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. * settings.py with middleware DEBUG = False ALLOWED_HOSTS = ["www.bancaintesa.com"] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] Here is the file views.py with handler404 def handler404(request): response = render_to_response('404.html', context_instance=RequestContext(request)) response.status_code = 404 return response urls.py file handler404 = 'intesa.views.handler404' Second thing, installed version of Django is 1.10, but when i run Django app on some irrelevant URL error, he shows me that Django is running on 1.8.7 version. Mindblowing. Any explanation? Does anybody knows what is happening or somethinf, Thank you, I appreciate it [very much] (sorry for bad english). -
Djano:Solr rebuild_index error 403
I am in process of Learning in Django. I have to build search engine for test application. I have search_indexes.py from haystack import indexes from .models import Post class PostIndex(indexes.SearchIndex, indexes.Indexable): text = indexes.CharField(document=True, use_template=True) publish = indexes.DateTimeField(model_attr='publish') def get_model(self): return Post def index_queryset(self, using=None): return self.get_model().published.all()` And I created and set up Solr core admin for my application. And when I try to execute python manage.py rebuild_index I get this error: raise SolrError(error_message % (resp.status_code, solr_message)) pysolr.SolrError: Solr responded with an error (HTTP 403): [Reason: None] And also following response in HTML (this is just a part of response): <h1>This Page Cannot Be Displayed</h1> <p> Based on your organization's security policies, this web site( http://127.0.0.1/solr/blog/update/?commit=true )has been blocked because it has been determined to be a securitythreat to your computer or the organization's network.Access could also be blocked because this request came from anunrecognized or unauthorized machine. </p> <p> If you have questions, please contactyour organization's network administrator and provide the codes shown below.</p> </div> I have "blog" application. I have Post model. I created in blog application directories blog/search/indexes/blog/post_text.txt image of blog core admin in solr Any help? Thanks. -
Receive obj must be an instance or subtype of type when trying to call a class method
I am trying to call a class method in a view. The method generates a url however when I try call the method using get_context_data I receive obj must be an instance or subtype of type when trying to call a class method models.py class Scenario(models.Model): name = models.CharField(max_length=256, blank=False, null=False, unique=True) description = models.TextField(max_length=1000) def get_absolute_url(self): return reverse('scenarios:detail', kwargs={'pk': self.pk}) def __unicode__(self): return self.name def generate_trade_url(self): if self.trade_set.exists(): return reverse('scenarios:trade-scenario', kwargs={'pk': self.pk}) return None views.py class Index(generic.ListView): template_name = 'scenarios/index.html' context_object_name = 'all_scenarios' def get_queryset(self): return Scenario.objects.all().order_by('name', 'description') class Detail(generic.DetailView): model = Scenario context_object_name = "scenario" template_name = 'scenarios/details.html' def get_context_data(self, **kwargs): context = super(Scenario, self).get_context_data(**kwargs) context['tradeurl'] = Scenario.generate_trade_url() return context urls.py url(r'^$', views.Index.as_view(), name='index'), url(r'^(?P<pk>[0-9]+)/$', views.Detail.as_view(), name='detail'), template <tbody> {% for scenario in all_scenarios %} <tr> <td><a href ="{% url 'scenarios:detail' scenario.id %}" data-toogle="tooltip" title="Click for filtered view">{{scenario.name}}</a></td> <td>{{scenario.description}}</td> <td> <a href="{% url 'scenarios:scenario-update' scenario.id %}"> <button type="submit" class="btn btn-default btn-sm"> <span class="glyphicon glyphicon-pencil" /> </button> </a> </td> <td> <form action="{% url 'scenarios:scenario-delete' scenario.id %}" method="post"> {% csrf_token %} <input type="hidden" name="scenario_id" value="{{ scenario.id}}"/> <button type="submit" class="btn btn-default btn-sm" onclick="return confirm('Are you sure you want to delete {{scenario.name}}?')"> <span class="glyphicon glyphicon-trash" /> </button> </form> </td> </tr> {% endfor … -
AlterField on auto generated _ptr field in migration causes FieldError
I have two models: # app1 class ParentModel(models.Model): # some fields Now, in another app, I have child model: # app2 from app1.models import ParentModel class ChildModel(ParentModel): # some fields here too In initial migration for app2 django creates OneToOneField with parent_link=True named parentmodel_ptr. Now I want to change this auto generated field to let's say IntegerField, so I create new migration with this operations: class Migration(migrations.Migration): dependencies = [ ('app2', '0001_initial'), ] operations = [ migrations.AlterField( 'childmodel', 'parentmodel_ptr', models.IntegerField(null=True, blank=True) ) ] Trying to migrate, I got an exception django.core.exceptions.FieldError: Auto-generated field 'parentmodel_ptr' in class 'ChildModel' for parent_link to base class 'ParentModel' clashes with declared field of the same name. So is that even possible to make it somehow? -
Proper model defination in django for a widget manager
I have a model called widgetManager and 2 widget models called emailWidget and TextWidget. Now a single instance of widgetManager can have multiple instances of emailWidget and TextWidget. How can this be achieved with the following in mind Till now i only have two but there can be more in future The order of widget is very important I have tried with adding two many-many relations in widgetManager but that seems impractical and not the best way to go around because if first condition. What i have in mind is maybe i can somehow make a base widget class and extend all the widgets from that class but i am not sure about that. Would be super helpful if someone can point me in the right direction. Thanks in advance. -
How not to call clean method in django model when editing?
I have a model called LeaseTerm .I want not to have more than 1 leaseTerm per specific Lease that is is_active and not is_terminated class LeaseTerm(CommonInfo): version = IntegerVersionField( ) start_period = models.ForeignKey(Period, related_name='start_period' ) end_period = models.ForeignKey(Period, related_name='end_period') lease = models.ForeignKey(Lease) increase = models.DecimalField(max_digits=7, decimal_places=2) amount = models.DecimalField(max_digits=7, decimal_places=2) is_terminated = models.BooleanField(default=False) def clean(self): model = self.__class__ if self.lease_id and (self.is_terminated == False) and model.objects.filter(lease=self.lease, is_active=True ).count() == 1: raise ValidationError('!Lease has a active condition already, Terminate prior to creation of new one'.format(self.lease)) For this I wrote a clean method that works perfectly when I create a new lease term. However this method is a problem when I do Edit since it counts itself and not allowing to save . Any recommendation how can I overcome this problem? I just want to skip the clean method when I edit. -
pass multiple arguments in the url
I'm trying to make a simple django app that interacts with the database. But I'm having trouble passing more than one parameter in the url. To pass the arguments i do it this way: 127.0.0.1:8000/REST/insert/?n=test/?x=2/?y=2/?z=True And then in my views.py I get the parameters with: name = request.GET.get('n', '') x = request.GET.get('x', '') y = request.GET.get('y', '') z = request.GET.get('z', '') Clearly I'm doing it wrong. How can I fix it ?