Quantcast
Channel: User Ciprian Tarta - Stack Overflow
Browsing latest articles
Browse All 31 View Live
↧

Comment by Ciprian Tarta on in django import error occurred as module not found

Updated my response. Let me know if you still have issues

View Article


Comment by Ciprian Tarta on Get all objects of a relation

What do you mean by get all persons, do you have a model Person for that? Is it related to Lab?

View Article

Comment by Ciprian Tarta on Django modelform integrate the fields for the...

If this answers your question, please mark it as the correct answer :)

View Article

Comment by Ciprian Tarta on different values of a django session variable in...

My understanding was that the search would not be an ajax call, only the filtering after the list is returned. If that's not the case, then see bellow

View Article

Comment by Ciprian Tarta on compare dates and validate] in django

ah sorry, it should be self.cleaned_data['fromdate'] I believe

View Article


Comment by Ciprian Tarta on disabled field is not passed through - workaround...

Nice, but what do you do in case of checkboxes. Ho do you distinguish between a checkbox being disabled or unchecked.

View Article

Comment by Ciprian Tarta on Django app - Virtualenv upgrading my package with...

It sounds to me that you need some sort of a bash script to help you with packing and unpacking your app. Or a git hook if you are using git.

View Article

Comment by Ciprian Tarta on Remove item[i] from jQuery each loop

the question was how to remove it from a loop.

View Article


Comment by Ciprian Tarta on Running a Python file with Flask, nginx and uWSGI...

Correct, forgot to escape __. @KevinKromjong, the correct package identifier for Python 2 is __init__.py For Python 3, there's no need for an __init__.py file.

View Article


Comment by Ciprian Tarta on How do I run inspectdb against different schemas...

The question was how to inspect schemas in Oracle, not Postgresql.

View Article

Comment by Ciprian Tarta on Angular 2 binding seems to be removed after an...

Done, but that code is very trivial.

View Article

Comment by Ciprian Tarta on Angular 2 binding seems to be removed after an...

@GünterZöchbauer you are correct about change detection failing. I've used the ChangeDetectorRef and manually triggered detectChanges() and the template updates correctly. This is a bit of a hack, but...

View Article

Comment by Ciprian Tarta on Angular 2 binding seems to be removed after an...

I've marked this as the correct answer. Also +1 @Günter since his input helped on figuring this out.

View Article


Comment by Ciprian Tarta on Django - best way of storing data created on the...

showroom_devices.append({"before": device, "after": completed_device_name})

View Article

Django transfer uploaded file

I'm trying to upload a file via django forms, then send it to an API.Here's the encoding function:#FYI, requestFile = request.FILES['file']def EncodeFile(self, requestFile, fields = []): BOUNDARY =...

View Article


Answer by Ciprian Tarta for Django transfer uploaded file

Apparently this line of code causes the problem:'Content-Disposition: form-data; name="file"; filename="%s"' % requestFile.name,The correct line would be instead:'Content-Disposition: form-data;...

View Article

Rails routing resource in namespace starting with a parameter

I have 2 namespaces, api and v1I have accounts and users as resources.I want to map the routing as follows for all my resources:/api/v1/:account_id/:resource/:idi.e:/api/v1/1/users/2In the example 1...

View Article


Answer by Ciprian Tarta for Rails filtering resource one to many through a...

This appears to be the only way I found this to be working if anyone is interested.CheckItem.joins(:item => {:category => :restaurant}).where('category.uuid=? and restaurant.id=?', 123123, 1)

View Article

Rails filtering resource one to many through a joint table

I have the following resources:- restaurant- category- item- check itemRelationship:class Restaurant < ActiveRecord::Base has_many :items has_many :categories has_many :check_itemsclass Category...

View Article

Answer by Ciprian Tarta for python django - csv file not getting downloaded...

Try this:csv_name = urllib.urlencode({'filename':'"results.csv"'}) #this is if you really really want the double quotes, otherwise just use cvs_name = 'results.csv'response = HttpResponse(csv_content,...

View Article

Answer by Ciprian Tarta for I can open picture from local, but when I visit...

You may want to rethink serving files through the django app.Instead you should serve them from /static folder which in an apache setup you would configure using an alias.That being said, check this...

View Article


Answer by Ciprian Tarta for Django URL Regex for an "Address"

r'(?<address>^\d{1,5}\s[a-zA-z\s]+,\s[a-zA-z]+,\s[A-Z]{,2}$)'This is about as strict as it gets.Basically what it does is:makes sure it starts with a numbermakes sure the the number is max 5...

View Article


Answer by Ciprian Tarta for select_related or select_prefetched after calling...

Yes you canAs you can see:type(MyModel.objects.filter(pk=1))<class 'django.db.models.query.QuerySet'>type(MyModel.objects.filter(pk=1).select_related())<class...

View Article

Answer by Ciprian Tarta for Join strings with "and" depending on single or...

' and '.join(x.name for x in result)

View Article

Answer by Ciprian Tarta for Print html tags in Django

You can use the escape filter {{variable|escape}}Same as php's htmlentities or htmlspecialchars

View Article


Answer by Ciprian Tarta for How to kill a python child process created with...

Manually you could do this:ps aux | grep <process name>get the PID(second column) andkill -9 <PID>-9 is to force killing it

View Article

Django triple relation with select/prefetch related?

I have the following models:class User(models.Model): ... @property def to_dict(): prefs = self.prefs.get() return {'id': self.pk, 'birthday': prefs.birthday}class UserPref(models.Model): user =...

View Article

Answer by Ciprian Tarta for Django test user password

What I would do is create the following assertions in the test_password_update test:user loginpassword updateuser loginIf the user is able to login after the password update, then you are safe and the...

View Article

Answer by Ciprian Tarta for Is python`s SysLogHandler nonBlocking?

The python documentation on logging is the main point where you should start.SysLogHandler is a subclass of Handler(There are many more. See the docs).This is the relevant part that you are looking for...

View Article



Answer by Ciprian Tarta for python - extend and replace if if-statement is true

Have you tried using filter?Like so:for i in filter(lambda x: x in [y for y in result if y[:2] == x[2:]] , list_byte): print(i)Basically, the lambda function returns true if your tuple is found in the...

View Article

Answer by Ciprian Tarta for Is there any Python equivalent to partial classes?

You can do this with decorators like so:class Car(object): def start(self): print 'Car has started'def extends(klass): def decorator(func): setattr(klass, func.__name__, func) return func return...

View Article
Browsing latest articles
Browse All 31 View Live