Re: Class Views

2011-10-06 Thread Vijay Khemlani
It should be "render_to_response", not "render_to_reponse", a spelling problem maybe? On Thu, Oct 6, 2011 at 12:53 PM, CrabbyPete wrote: > I have the following class defined > > class TeamView(TemplateResponseMixin, View): >template_name = 'team.html' > >def

Facebook Authentication: Client side vs. Server side

2011-10-18 Thread Vijay Khemlani
Hello, I'm just starting with a project that requires users to be able to authenticate directly using their Facebook accounts. I know this is an old problem, but I noticed there are two quite distinct ways to solve it, and I wanted to ask for the group's opinion 1. Using FB JavaScript SDK

Re: Unable to access view variable

2014-10-16 Thread Vijay Khemlani
You need to pass a dictionary as a second parameter to the render_to_response method with the variables that you wish to access in the template. for example: return render_to_response('index.html', {"people_info": pers}) that way you can access the variable "people_info" in the template. On

Re: Unable to store static

2014-10-16 Thread Vijay Khemlani
It would be useful to see the path rendered in the final HTML in the document, as it could be related to the "STATIC_URL" setting or some other cause. On Thu, Oct 16, 2014 at 11:44 AM, Babatunde Akinyanmi wrote: > > On 16 Oct 2014 15:36, tundeba...@gmail.com wrote: > > > >

Re: Generic Views and Django.contrib.auth

2014-10-16 Thread Vijay Khemlani
If you are usign class based generic views you can use the decorators in the URL config of your app, for example urlpatterns = patterns('', (r'^about/', login_required(AboutView.as_view())), ) On Thu, Oct 16, 2014 at 12:49 PM, Rootz wrote: > Can I use both Generic View

Re: Unable to store static

2014-10-16 Thread Vijay Khemlani
I agree, but we need to determine where the problem lies. is the STATIC_URL param OK? is the STATICFILES_DIRS setting correct? I think the starting point is checking whether the url to the static asset is being determined correctly and then move forward. On Thu, Oct 16, 2014 at 3:00 PM, Daniel

Re: how to update data in FK fields another Model

2014-10-16 Thread Vijay Khemlani
I think the argument to the F object should be just the name of the field on ModelA: product.field_count = F('field_count') + 1 Other than that, there are a few weird things about the code, for example: product = ModelA.objects.get(id=self.fk_name.id) Why not just use product =

Re: how to update data in FK fields another Model

2014-10-16 Thread Vijay Khemlani
Vijay you suggestion not working no increment the field_count :/ any > other idea > > Cheers > > On Thu, Oct 16, 2014 at 2:44 PM, Vijay Khemlani <vkhem...@gmail.com> > wrote: > >> I think the argument to the F object should be just the name of the field >&

Re: NoReverseMatch error

2014-10-18 Thread Vijay Khemlani
I think you need to pass the "type" and "state" values in the {% url ... %} tag https://docs.djangoproject.com/en/1.7/ref/templates/builtins/#url On Sat, Oct 18, 2014 at 6:06 PM, Daniel Grace wrote: > Hi, > I get the following error on one of my view forms: > Request

Re: Django model complex query ( use table A.column1 as parameter to query result from table B)

2014-10-21 Thread Vijay Khemlani
I think you are trying to establish a many-to-many relationship between the models, that way it would be like this poiRes = models.ManyToManyField(POIS) and the candidatePois is unnecessary in that case. On Tue, Oct 21, 2014 at 3:16 PM, zhang rock wrote: > Hi All, >

Re: TypeError: can't concat bytes to tuple

2014-10-27 Thread Vijay Khemlani
Well, this is not a Django-related question, but still. The tutorial you are following uses Python 2.5.1, which differs a lot from the Python 3.4 that you are using. If you want to still follow that tutorial you'd better install Python 2.7, which is more compatible with 2.5 Also, try printing

Re: How not to explicly write very very big json object when rendering page in django template ?

2014-11-02 Thread Vijay Khemlani
Do you really need all the data in that dictionary for the page? You could request the necessary parts by AJAX after the page has loaded. On Sun, Nov 2, 2014 at 6:59 PM, Matlau Issu wrote: > I mean, in my views.py i do : > return render(request, 'myapp/detail.html', {

Re: DecimalField returns 'This value must be a decimal number' when blank

2014-11-16 Thread Vijay Khemlani
I'm not sure if a syncdb changes the null attribute of a field at the DB level, I think you need to make a migration for that. Either way, it would be useful if you could post the declarations of the form and the model to see if everything is ok. On Sun, Nov 16, 2014 at 2:51 PM, elcaiaimar

Re: Form doesn't show in HTML template

2014-11-20 Thread Vijay Khemlani
If you set the settings TEMPLATE_DEBUG to True, does it display any errors? On Thu, Nov 20, 2014 at 6:39 PM, Some Developer wrote: > On 20/11/14 21:15, James Schneider wrote: > >> Dumb question, but there is a "main_content" block in base.html, right? >> >> I'm

Re: Form doesn't show in HTML template

2014-11-21 Thread Vijay Khemlani
If you manually call the form "as_p" method in the view (not the template), does it print the form? On Fri, Nov 21, 2014 at 12:28 PM, Some Developer <someukdevelo...@gmail.com> wrote: > On 20/11/14 22:07, Vijay Khemlani wrote: > >> If you set the settings TEMPLATE_DE

Re: Using Sum() for a models method inside a Query

2014-11-23 Thread Vijay Khemlani
What do you mean by the sum or average of the method? As in the sum or average of the method applied to a list of objects "X"? On Sun, Nov 23, 2014 at 7:41 PM, Jorge Andrés Vergara Ebratt < javebr...@gmail.com> wrote: > Hello everyone, > > Well, the tittle says it all: > > I have a model X > >

Re: How to make database queries that “filters” results according to tuples of values?

2014-11-26 Thread Vijay Khemlani
I think you could construct a Q object like this: from django.db.models import Q query = Q() for preference in user.preferences.all(): query |= Q(dish=preference.dish) & Q(ingredient=preference.ingredient) Meal.objects.filter(query) That returns the meals where their (ingredient, dish)

Re: Re: How to make database queries that “filters” results according to tuples of values?

2014-11-27 Thread Vijay Khemlani
ry much. I have not known, that |= also could be used on Q(). > Thought Q is only there for making "or" "not" and so stuff of calls! Great! > > Best Regards, > Mike > > *Gesendet:* Mittwoch, 26. November 2014 um 20:30 Uhr > *Von:* "Vijay Khemlani"

Re: Error: 'NoneType' object has no attribute 'strip'

2014-12-01 Thread Vijay Khemlani
Have you tried following the stacktrace that resulted in the error? Does it fail when trying to strip the contents of the "name" field? On Mon, Dec 1, 2014 at 10:16 AM, Danish Ali wrote: > I am using admin to enter data. > This is the URL from where I am trying to save

Re: TypeError: unbound method save() must be called with NagiosLog instance as first argument (got nothing instead)

2014-12-06 Thread Vijay Khemlani
Call k.save() instad of NagiosLog.save() On Sat, Dec 6, 2014 at 8:26 AM, Phil F wrote: > Hi, > > I am attempting to write a python script that will populate the Django db > from data stored in a dictionary. > > I'm currently getting the error :"TypeError: unbound

Re: set current user value in Django admin for Foreign Key

2014-12-10 Thread Vijay Khemlani
Hmmm... why are you showing the user field in the first place? I would exclude it from the form and set it programatically after the user as submitted the form. On Wed, Dec 10, 2014 at 5:38 AM, Akshay Mukadam wrote: > Hi, > I just want to show the current logged in

Re: Need to search through several tables using one model

2014-12-12 Thread Vijay Khemlani
Just using the ORM I think not You could 1. Make a raw sql query using UNIONs for each table 2. Make a common superclass for the models with th search field 3. Use an external search engine (elasticsearch, etc) and store the entries for the required models under the same index. Finally, you

Re: Need to search through several tables using one model

2014-12-13 Thread Vijay Khemlani
What search button are you talking about? On Sat, Dec 13, 2014 at 2:23 PM, Alon Nisser wrote: > > You could also create a model that foreign keys to all the relevant > models, and filter on that.. > Buy first you need to clarify (for your self..) The exact use case: is it >

Re: Need to search through several tables using one model

2014-12-15 Thread Vijay Khemlani
think, I think it's need to overriden in order to implement >> custom model or something. >> >> On Sat, Dec 13, 2014 at 11:06 PM, Vijay Khemlani <vkhem...@gmail.com> >> wrote: >>> >>> What search button are you talking about? >>> >

Re: how to connect parse.com with parse-rest

2014-12-15 Thread Vijay Khemlani
Are you running the dev server while having the viartualenv activated? On Mon, Dec 15, 2014 at 11:19 AM, Carlos Ons wrote: > > I cannot connect to parse.com with parse-rest API. > > I have a virtualenv installed and when I try to connect to parse.com It > is impossible. I

Re: How can I add an attribute to each option in a django model form containing a foreign key?

2014-12-15 Thread Vijay Khemlani
If the crispy form is using the usual render methods of Django you can subclass the Select class (in forms/widgets.py), reimplement the "render_option" method and add the parameter to the returned HTML, then you can set the widget attribute of the form field to your created class. I don't know

Re: CBV with inline formset

2014-12-15 Thread Vijay Khemlani
Try changing the name of the parameter in the url from author_id to pk On Mon, Dec 15, 2014 at 5:39 PM, Brad Rice wrote: > > I've pretty much butchered the code for 3 days now and cannot figure out > how to insert an inline formset. Can anybody help me? > > I've tried to

Re: ANN: Django website redesign launched

2014-12-17 Thread Vijay Khemlani
I really like the new design, the old one felt way too cluttered with too much information on the main page and overwhelmed new users. And... haters gonna hate. Congrats to the team! On Wed, Dec 17, 2014 at 10:37 AM, Daniele Procida wrote: > > On Wed, Dec 17, 2014, Rob

Re: Raw access to cache table

2014-12-18 Thread Vijay Khemlani
I'm not sure that using a cache system as a lock mechanism is a good idea. What I would do is setup a task queue (using celery and rabbitMQ) with a single worker, that way you guarantee that only one task is running at a time and you can queue as many as you want. Also, each task has a maximum

Re: filter Datetimefield

2014-12-21 Thread Vijay Khemlani
When you print the SQL query that is executed on the database print lista_de_balada.query Does it make sense? When you see the actual value stored in the database is it stored correctly? Also remember that the month and day are 1-based (january is 1, february is 2, etc) Suerte! :D On Sun,

Re: How to capture any incorrect typing of a url and pass it to a default page

2014-12-24 Thread Vijay Khemlani
Try adding the *args and **kwargs parameters def my_default_2(request, *args, **kwargs): ... On Wed, Dec 24, 2014 at 1:15 PM, pythonista wrote: > I want to code the urls.py such that if someone types in any garbage inn > the browser the final line of

Re: Two Django projects with common models and business logic

2014-12-24 Thread Vijay Khemlani
You can version it under a different repository, clone it in each server, and then add that path to the PYTHONPATH of each project, or just make a symbolic link to the app. On Wed, Dec 24, 2014 at 1:18 PM, andy wrote: > Thank you. Since it's only me that'd be using the

Re: Storing files to Google Cloud Storage or Amazon S3 using Python 3.4

2014-12-27 Thread Vijay Khemlani
What error are you getting when using storages-redux? On Sat, Dec 27, 2014 at 5:15 PM, Some Developer wrote: > I know about Django storages (which is not compatible with Python 3.4) and > Django storages redux (which is compatible with Python 3.4 but gives an > error

Re: delete OnetoOneField link

2014-12-30 Thread Vijay Khemlani
If you want to change a user's cashbox then yes, you would need to use your solution, but it's easier to get c1 by just saying c1 = user.cashbox instead of Cashbox.objects.get A more definite solution would be to add the OneToOne relation to the User model instead of the Cashbox object, but

Re: Can't save input to database

2014-12-30 Thread Vijay Khemlani
the code sample links are broken :( On Tue, Dec 30, 2014 at 4:59 PM, Thomas Lockhart wrote: > On 12/30/14 11:42 AM, Ronis wrote: > > Hi guys, I can't save the input from a custom form to database. I don't > know what I am missing. > > I'm not sure either. But the html

Re: Write Multiple Text Files into a Single CSV File

2014-12-31 Thread Vijay Khemlani
I'm not too sure about the format of the content, but maybe this to create the file? import csv files = ['f1.txt', 'f2.txt', 'f3.txt'] with open('output.csv', 'wb') as f: writer = csv.writer(f) for input_file_name in files: with open(input_file_name, 'r') as input_file:

Re: Trying out django your first app.

2015-01-01 Thread Vijay Khemlani
For me the development server tends to throw that error at random, but does render the page correctly On Thu, Jan 1, 2015 at 2:22 PM, Joel Goldstick wrote: > > > On Thu, Jan 1, 2015 at 3:55 AM, Siddharth Shah > wrote: > >> Actually I was going

Re: How to deplou 2 different django website in nginx?

2015-01-04 Thread Vijay Khemlani
as far as i know about nginx, server names are not separated by commas, just spaces. On Sun, Jan 4, 2015 at 3:51 PM, Fellipe Henrique wrote: > Hi there! > > I`m trying to make my nginx server work with 2 domains, with 2 different > django websites. > > So, I have a big, big

Re: Expected performance of the django development server?

2015-01-05 Thread Vijay Khemlani
1189 queries is quite a large amount, are all of those really needed? I think some profiling is in order. On Mon, Jan 5, 2015 at 3:09 AM, Jani Tiainen wrote: > On Sun, 4 Jan 2015 20:41:58 -0800 (PST) > Richard Brockie wrote: > > > Hello again, > >

Re: Error: No module named polls

2015-01-05 Thread Vijay Khemlani
Also make sure that there is an __init__.py file in the polls directory On Mon, Jan 5, 2015 at 12:47 PM, Xavier Ordoquy wrote: > Hi, > > > Le 5 janv. 2015 à 16:41, ibes ... a écrit : > > hello, > I am frustrated with django and phyton tutorial it is

Re: Not able to update a form in Django after post method

2015-01-05 Thread Vijay Khemlani
For starters, validate the form before getting its data smsPduForm = SmsPduForm(request.POST) if smsPduForm.is_valid(): d = smsPduForm.cleaned_data smsc = d['SMSC'] # etc... regarding the form assignment, I'm not too sure what you're trying to do. ¿Do you want to display the same

Re: is there a Django library for AJAX support

2015-01-05 Thread Vijay Khemlani
I don't think Python is the right tool for frontend development. There are entire (and good) frameworks oriented to frontend using JavaScript (such as AngularJS), that also take care of DOM manipulation, handling events, encapsulating ajax requests, etc. On Mon, Jan 5, 2015 at 8:11 PM, Martin

Re: CSRF verification failed when I use smart phone

2015-01-06 Thread Vijay Khemlani
¿Did you include de {% csrf_token %} tag in the form? ¿Is it generating the corresponding hidden input tag in the html? On Tue, Jan 6, 2015 at 6:09 AM, Sugita Shinsuke wrote: > Hello. > > When I use Django via my smart phone Android and iOS. > The error sometimes occurred. >

Re: Recommendations for hosting service?

2015-01-06 Thread Vijay Khemlani
I like Linode, and DigitalOcean is also a great choice. Both require low-level configuration of the server but I prefer that over the pre-packaged solutions. On Tue, Jan 6, 2015 at 10:44 AM, Brad Rice wrote: > I like webfaction, too. I think they would have all the stuff

Re: Matching logic is case sensitive when I want it case insensitive

2015-01-06 Thread Vijay Khemlani
on line 12 you would need a more complex logic try: obj = SocialAccount.objects.get(social_profile=profile, service=service, value__iexact=value) except SocialAccount.DoesNotExist: obj = SocialAccount.objects.create(social_profile=profile, service=service, value=value) (assuming "value"

Re: Serving static files and media in Django 1.7.1

2015-01-06 Thread Vijay Khemlani
the static tag should be {% static 'mainsite/bootstrap.css' %} according to the layout you said On Tue, Jan 6, 2015 at 8:30 PM, Sithembewena Lloyd Dube wrote: > Hi everyone, > > I have a Django 1.7.1 project structured as per documentation. In it, I > have an app called

Re: Pulling data from two table

2015-01-08 Thread Vijay Khemlani
Please be more specific in your question, how are these tables related? what models are they associated with? On Thu, Jan 8, 2015 at 6:01 PM, sum abiut wrote: > Hi, > can someone please help. i am trying to pull data from two table in django > and display the results. can

Re: Pulling data from two table

2015-01-08 Thread Vijay Khemlani
models.DateField() > username =models.ForeignKey(User, default =1) > staff =models.ForeignKey(staff, default =1) > > def __unicode__(self): > return self.leave_type > > > > > > On Fri, Jan 9, 2015 at 8:32 AM, Vijay Khemlani <vkhem...@gmail.com&g

Re: Pulling data from two table

2015-01-08 Thread Vijay Khemlani
th model. i can pull out > information in each table but i am a but confuse in joining the two tables > together. something like NATURAL JOIN in mysql. > > Cheers, > > > On Fri, Jan 9, 2015 at 12:07 PM, Vijay Khemlani <vkhem...@gmail.com> > wrote: > >> OK, wha

Re: updating data in a row

2015-01-08 Thread Vijay Khemlani
You have two choices 1. Change the URL mapping and pass the "id" in the url url(r'^update_form/(?P\d+)/$', 'eLeave.views.update_form'), (then the url is something like /update_form/15/) 2, Change the view so that it only accepts the "request" argument def update_form(request): in that case

Re: How to run background application via Django

2015-01-08 Thread Vijay Khemlani
Have you done the celery tutorial? Async tasks require you to have a broker (rabbitmq or something) and also to create some workers that actually execute the task. On Fri, Jan 9, 2015 at 12:55 AM, Sugita Shinsuke wrote: > Hi somecallitblues > > Thank you for replying. > I

Re: Return to the requested page after successfull @login_required by the next variable

2015-01-09 Thread Vijay Khemlani
Add the "next" variable as part of the form in a hidden field ... other fields... and then you can get it in the view that handles the login Also, you seem to have a form object, why don't you use "form.as_p" or something like that to render the form? On Fri, Jan 9, 2015 at 2:02 AM,

Re: updating data in a row

2015-01-11 Thread Vijay Khemlani
L are you visiting and can you post the traceback? >> On Jan 8, 2015 9:25 PM, "sum abiut" <suab...@gmail.com> wrote: >> >>> Hi, >>> I have change the URL mapping to url(r'^update_form/(?P\d+) >>> /$', 'eLeave.views.update_form'), >>> >>> but i am

Re: New data field in models.py "does not exist".

2015-01-12 Thread Vijay Khemlani
sqlall only prints the commands that would be executed to create the database from scratch, it does not output your current database schema if you are using django 1.7, then you need to create a migratino and apply it python manage.py makemigrations python manage.py migrate On Mon, Jan 12, 2015

Re: New data field in models.py "does not exist".

2015-01-12 Thread Vijay Khemlani
Then you need to install south and configure it or update to django 1.7 On Mon, Jan 12, 2015 at 4:54 PM, dennis breland wrote: > I am using Django 1.6 > > > On Monday, January 12, 2015 at 1:16:17 PM UTC-5, dennis breland wrote: > >> All works fine before making this

Re: New data field in models.py "does not exist".

2015-01-12 Thread Vijay Khemlani
ngo is just passing it along). >> >> You should also try running syncdb again. It should be an idempotent >> operation, assuming that you haven't made any other changes to your model >> code, so you can run it as many times as you want. >> >> -James >> On

Re: filter

2015-01-15 Thread Vijay Khemlani
in your view new_leave and a are QuerySet objects, and then you are comparing them to a string ("True") not a bolean (True without quotes), so it's always False. Even if you change "True" to True it won't work, try it like this if new_leave.exists() and a.exists(): return ... On Thu, Jan 15,

Re: filter

2015-01-15 Thread Vijay Khemlani
{{a.remarks}} > {{a.authorization_date}} > > > {%endfor%} > > > > > view.py > > > def FMKD1_leave_to_authorize(request): > new_leave > =newleave.objects.filter(department_head_authorization="Approved" ) > new_leave = newleave.objects.filter(de

Re: How to check appname via Django commands?

2015-01-17 Thread Vijay Khemlani
What problem are you having exactly? Also I'm not sure what do you mean by "hierarchy" of the project folders, do you mean the order the apps appear in the INSTALLED_APPS setting? On Sat, Jan 17, 2015 at 6:38 AM, Sugita Shinsuke wrote: > Hi there. > > I use Django 1.6

Re: Using jquery ajax POST method with django

2015-01-17 Thread Vijay Khemlani
Maybe it's triggering the CSRF validation? What error message are you getting exactly from the server? On Sat, Jan 17, 2015 at 10:37 AM, Erwin Sprengers wrote: > Hello, > > POST works fine for me, I use the following django code : > > at the end of the view : > > return

Re: Best way to test handle optional FKs in model __str__?

2015-01-17 Thread Vijay Khemlani
I don't think there is a way in Python to do that directly you could have a utility method that catches the exception, for example def get_fk_field(obj, fk_field): try: return getattr(obj, fk_field) except AttributeError: return None so that your call would be return

Re: How to subclass django-contact-form to create custom contact form?

2015-01-19 Thread Vijay Khemlani
Right now the "reportForm" variable is pointing to the RequestForm class, not to an object, so you need to do it like this reportForm = ReportForm()# Take note of the parenthesis In your template, your form tag need an action attribute (well, it's not mandatory but it is highly advised). In

Re: How to subclass django-contact-form to create custom contact form?

2015-01-19 Thread Vijay Khemlani
OK, I read a little of the library documentation, and this is what you have to do I think 1. subclass the ContactForm (you already have that) 2. subclass the ContactFormView from the library, at least with this: class ReportFormView(ContactFormView): form_class = ReportForm 3. Map this view

Re: Desperately need Django help!

2015-01-19 Thread Vijay Khemlani
For single page applications I highly recommend this tutorial, it answers the typical questions regarding single page apps. https://thinkster.io/brewer/angular-django-tutorial/ (assuming you are using angularJS) On Mon, Jan 19, 2015 at 5:08 AM, wrote: > Hi, I am trying

Re: can't install the pillow library on my first attempt to add an ImageField to my model

2015-01-21 Thread Vijay Khemlani
You need to install the development python package for your distro For example, in Ubuntu sudo apt-get install python-dev in Fedora sudo yum install python-devel On Wed, Jan 21, 2015 at 10:44 AM, aseds wrote: > hi, > this is the first time i tried and added an

Re: can't install the pillow library on my first attempt to add an ImageField to my model

2015-01-21 Thread Vijay Khemlani
chmod 777 dist-packages > or what should i do? > > On Wednesday, January 21, 2015 at 6:13:23 AM UTC-8, Vijay Khemlani wrote: >> >> You need to install the development python package for your distro >> >> For example, in Ubuntu >> >> sudo apt-get install

Re: login_required in urlpatterns TypeError 'tuple' object is not callable

2015-01-23 Thread Vijay Khemlani
I may be mistaken, but I don't think you can decorate an entire "include" call On Fri, Jan 23, 2015 at 8:51 PM, Neto wrote: > Hi, I'm using login_required in url patterns but it does an error: > > urls.py > > from django.conf.urls import patterns, include, url > from

Re: How to properly set the initial value for a Form ChoiceField

2015-01-23 Thread Vijay Khemlani
It could be a number of things, but the main thing that caught my attention was this part self.fields['images'].initial = str(selected_image) self.fields['images'].initial = str(selected_flavor) shouldn't it be self.fields['images'].initial = str(selected_image)

Re: Help in Django-contact-form

2015-01-27 Thread Vijay Khemlani
And I'm not following, contact_form does not provide a ContactForm model, but you are providing one it seems, but it's on the same contact_form package as the library itself? Also, the fact that the model class has the same name as the form class does not help much. On Tue, Jan 27, 2015 at 10:45

Re: Best way to get ForeignKey Related Objects?

2015-01-29 Thread Vijay Khemlani
"answers" seems to be a method on the AudioQuestionPair class, so your call should be: for answer in pair.answers(): print answer and "pair.answers.get.all()" does not make sense sinse "answers" is a method. If you don't want to use a specific method, you can do this: answers =

Re: Best way to get ForeignKey Related Objects?

2015-01-29 Thread Vijay Khemlani
AM, Tobias Dacoir <falc...@gmail.com> wrote: > Damn, you are right. pair.answers() works. I'm wondering why I didn't get > a syntax error when calling it without the parenthesis (), because print > still worked. > > On Thursday, January 29, 2015 at 2:59:56 PM UTC+1, Vijay Khemla

Re: When do I have to call save() on a Model Instance?

2015-01-29 Thread Vijay Khemlani
You could pass the user as an optional parameter to function2. Whether you should save the user or not in each of the methods depends on the logic of your application, or you can add a parameter to the method (True to save the object, False otherwise) On Thu, Jan 29, 2015 at 1:43 PM, Tobias

Re: When do I have to call save() on a Model Instance?

2015-01-29 Thread Vijay Khemlani
yep, it's safe to do so On Thu, Jan 29, 2015 at 3:40 PM, Tobias Dacoir wrote: > Thanks for answering all my questions. > > So it's perfectly save to call the save method at a later time? As long as > I keep the object and a pointer to it in memory I can freely modify it in >

Re: Do Signals block Django process?

2015-01-30 Thread Vijay Khemlani
The number of threads is determined by the number of workers in your process that is serving the application, not Django itself. For example, if you are using uWSGI to serve the application, then you have a parameter "workers" in its initialization file that sets the number of process to spawn

Re: How to get hold of a session after getting signaled?

2015-01-30 Thread Vijay Khemlani
As far as I can tell on the project source, the only place the "badge_awarded" signal is triggered is in the "award_to" method in the Badge class, which does not handle a request object. If you are calling something like "badge.award_to(user)" in one of your views, then you can modify the request

Re: incorrect syntax of django core management __init.py file (reported on windows powershell)

2015-01-31 Thread Vijay Khemlani
Django 1.3 only works with python 2, not python 3 On Sat, Jan 31, 2015 at 2:31 PM, Akshit Arora wrote: > hey, I am working on this project that requires django with apache > > https://github.com/nbproject/nbproject > > it's installation guide is here : > >

Re: Initial stages of django

2015-01-31 Thread Vijay Khemlani
Did you take a look at the official tutorial? https://docs.djangoproject.com/en/1.7/intro/tutorial01/ On Sat, Jan 31, 2015 at 5:02 PM, Sreenivasarao Pallapu < sreenivas.eng...@gmail.com> wrote: > Hi, >I'm new to django. I know basic python. I heard that django is nothing > but python. I've

Re: PermissionError with open()

2015-02-02 Thread Vijay Khemlani
Your call to ".format(file_name)" does nothing as the original string does not have the positional arguments ("{0}" for example) You could just append the filename with "+". On Mon, Feb 2, 2015 at 3:32 AM, John wrote: > Hello everyone, > > I am trying to run this code

Re: ListView and Deleteview

2015-02-02 Thread Vijay Khemlani
Hmmm... Try and post your urls.py and views.py (the correct one) On Mon, Feb 2, 2015 at 5:20 PM, Dan Gentry wrote: > This is a bit of a stumper! > > I don't see any big glaring issues. A couple of housekeeping things: Is > there data in the table? Are you certain that

Re: Writing your first Django app, part 1 - Django 1.7 - # Make sure our __str__() addition worked.

2015-02-04 Thread Vijay Khemlani
The method is called "__str__" (note the double underscore at both ends) On Wed, Feb 4, 2015 at 2:29 PM, Gavin Patrick McCoy < gavin.mcc...@mail.dcu.ie> wrote: > Hi, > > Just started learning Django today. I got down to the last grey box of > code on >

Re: Writing your first Django app, part 1 - Django 1.7 - # Make sure our __str__() addition worked.

2015-02-04 Thread Vijay Khemlani
Don't worry :) On Wed, Feb 4, 2015 at 7:00 PM, Gavin Patrick McCoy < gavin.mcc...@mail.dcu.ie> wrote: > Sorry about that. Thanks a million for your reply. > > On Wednesday, 4 February 2015 17:38:16 UTC, Vijay Khemlani wrote: >> >> The method is called "__st

Re: subdomains and HOST in settings.py?

2015-02-05 Thread Vijay Khemlani
I'm not following, in the Django settings there is no "HOST" entry (other than the one used to connect to the database) https://docs.djangoproject.com/en/1.7/ref/settings/ If you're talking about "ALLOWED_HOSTS", then that one is only a whitelist of allowed domains. Try and describe your

Re: models, peeking to next record - maybe

2015-02-07 Thread Vijay Khemlani
The direct solution would be something like this in your view events = Event.objects.order_by('event_date') event_tuples = [] last_date_seen = None for event in events: if last_date_seen: date_difference = event.date - last_date_seen else: date_difference = None

Re: Contact form and sending confirmation an page.

2015-02-08 Thread Vijay Khemlani
One way would be to render the page after the submit and scroll down to the form. Other would be submitting the form by ajax. On Sun, Feb 8, 2015 at 6:30 PM, inoyon artlover KLANGRAUSCH < inoyonartlo...@googlemail.com> wrote: > Hi there! > > I got one page. On the page is a contact form. >

Re: passing a list of list to a template

2015-02-12 Thread Vijay Khemlani
If you have a fixed number of items in each of the sublists you can do {{ i.0 }} # First element {{ i.1 }} # Second element or you can iterate over it {% for sub_element in i %} {{ sub_element }} {% endfor %} On Thu, Feb 12, 2015 at 2:55 PM, dk wrote: > i do have a

Re: passing a list of list to a template

2015-02-13 Thread Vijay Khemlani
tements too? like if i.2 == to somestuff? do something? or > all that need to be set in the view function? > > thanks > > > On Thursday, February 12, 2015 at 12:15:50 PM UTC-6, Vijay Khemlani wrote: > >> If you have a fixed number of items in each of the sublists you can

Re: how to get a link to an absolute hyperlink

2015-02-13 Thread Vijay Khemlani
Try adding "http://; at the start Also, consider that the format is 111.111.111.111: (the port is after a colon, not a dot) On Fri, Feb 13, 2015 at 8:03 PM, dk wrote: > its just a string with an ip address and that's it. > > {{ j }} > so at the end should be something

Re: html response to be loaded in a div

2015-02-18 Thread Vijay Khemlani
What is the actual content of the response you are getting from the AJAX request? On Wed, Feb 18, 2015 at 10:27 AM, João Marques wrote: > Hey guys, so basicly I want to send a GET request with ajax to one of my > views and the specific view returns an html response

Re: html response to be loaded in a div

2015-02-18 Thread Vijay Khemlani
. On Wed, Feb 18, 2015 at 1:47 PM, João Marques <joao6697marq...@gmail.com> wrote: > Im getting nothing really... I just do alert(response); and nothing shows > up. > > quarta-feira, 18 de Fevereiro de 2015 às 14:48:48 UTC, Vijay Khemlani > escreveu: >> >> What is t

Re: html response to be loaded in a div

2015-02-18 Thread Vijay Khemlani
What is being sent to the view from the browser is fine, it's just being url encoded, the actual value is something like this then: [[['5E', '10A', '8D'], ['8B', '11B', '12G'], ['8C', '7B'], ['12C', '11F', '6A'],['5E', '10G', '10H'],['8A','11E'], ['7A', '12E', '12F'], ['5A', '11C', '12B','11G'],

Re: How to install django in redhat where i have python 2.6 and 2.7 and i need to install django in python 2.7

2015-02-19 Thread Vijay Khemlani
you can compile python locally On Thu, Feb 19, 2015 at 10:27 AM, SHINTO PETER wrote: > How to install django in redhat where i have python 2.6 and 2.7 and i need > to install django in python 2.7 > > -- > You received this message because you are subscribed to the Google

Re: JSON Response

2015-02-19 Thread Vijay Khemlani
What do you mean with "in a good way"? Does your code work? On Thu, Feb 19, 2015 at 4:14 PM, elcaiaimar wrote: > Hello, > > I was wondering how I can send a response JSON in a good way, because I > have the next code: > > if "product_id" in request.POST: > try: >

Re: JSON Response

2015-02-19 Thread Vijay Khemlani
e with {"status":"True","product_id":p.id} But this should be > read for the JS code, and if it's True show an alert saying Remove it! > > Is there anything wrong in my code? > > El jueves, 19 de febrero de 2015, 21:49:59 (UTC+1), Vijay Khemlani > escrib

Re: html response to be loaded in a div

2015-02-19 Thread Vijay Khemlani
There's no "range" in django templates, you just use {% for elem in sols %} Regarding making the request using POST, are you sure you're not having a proble with CSRF? https://docs.djangoproject.com/en/1.7/ref/contrib/csrf/ It has a section for AJAX requests On Thu, Feb 19, 2015 at 7:44 PM,

Re: Transcode video using celery and ffmpeg in django

2015-02-20 Thread Vijay Khemlani
I would do something like this video = Video() video.original = form.cleaned_data['video'] # Assuming the form field is "video" video.user = user video.title = form.cleaned_data['title'] # Assuming the form field is "title" video.save() # You might need to make the mp4_480 and

Re: Transcode video using celery and ffmpeg in django

2015-02-20 Thread Vijay Khemlani
Then in your task function you can get the file from the video model instance, trascode it, and store it in the corresponding fields of the object (mp4_480, mp4_720) On Fri, Feb 20, 2015 at 10:18 AM, Vijay Khemlani <vkhem...@gmail.com> wrote: > I would do something like this > >

Re: html response to be loaded in a div

2015-02-20 Thread Vijay Khemlani
a little > while I manage to get the rest of the essential things to work. > > sexta-feira, 20 de Fevereiro de 2015 às 00:08:32 UTC, Vijay Khemlani > escreveu: >> >> There's no "range" in django templates, you just use >> >> {% for elem in sols %} >&g

Re: Design question: Is it really a good idea for models having “side effects”?

2015-02-20 Thread Vijay Khemlani
I'm not sure if there's an official stance on that, but I believe that since Django is a "MVT" framework, that kind of logic does not seem to be appropiate neither for templates nor views, so models seem like the logical choice. That way you can also make sure that the side-effect that you want

Re: Transcode video using celery and ffmpeg in django

2015-02-20 Thread Vijay Khemlani
o that I > can use ffmpeg code (subprocess.call('ffmpeg -i path/.../original > path/.../mp4_720') to transcode. > > Thank you. > > On Fri, Feb 20, 2015 at 6:49 PM, Vijay Khemlani <vkhem...@gmail.com> > wrote: > >> Then in your task function you can get the file fr

Re: html response to be loaded in a div

2015-02-20 Thread Vijay Khemlani
If you're using jQuery 1.5.1 or above you can do this instead // using jQuery function getCookie(name) { var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) {

  1   2   3   4   >