Re: Row based permissions: In DB or App? ... farewell pain

2017-08-10 Thread Vijay Khemlani
> > > Am Mittwoch, 9. August 2017 18:03:44 UTC+2 schrieb Vijay Khemlani: >> >> https://django-guardian.readthedocs.io/en/stable/userguide/ >> check.html#get-objects-for-user >> >> projects = get_objects_for_user(request.user, 'projects.view_project')

Re: How to use try..except, but when DEBUG is True, show the error?

2017-08-12 Thread Vijay Khemlani
from django.conf import settings try: x = parse_date('') except TypeError: if settings.DEBUG: raise else: return False On Sat, Aug 12, 2017 at 10:54 AM, Fellipe Henrique wrote: > Hello, > > i have these code, for example: > > try: >x = parse_date('') > except TypeErr

Re: Row based permissions: In DB or App? ... farewell pain

2017-08-16 Thread Vijay Khemlani
So, please share the specific numbers you got from your profiling. On Wed, Aug 16, 2017 at 6:10 AM, guettli wrote: > > > Am Donnerstag, 10. August 2017 14:30:31 UTC+2 schrieb Vijay Khemlani: >> >> It's still implemented like that in the background, but I'm not

Re: Making/Creating a verified user for unit test (django-allauth)

2017-08-17 Thread Vijay Khemlani
Check that the created user has the "is_active" field set to True On Thu, Aug 17, 2017 at 2:41 AM, Desmond Lim wrote: > Hi there, > > I'm wonder, how do we create a verified user for testing purpose > > I have this line that creates a user > > *cls.user = get_user_model().objects.create_user(use

Re: Row based permissions: In DB or App? ... farewell pain

2017-08-17 Thread Vijay Khemlani
bject-level permissions extensively in my own project and haven't had any performance issues yet. If nothing else, your results would prove useful to the community. On Thu, Aug 17, 2017 at 10:18 AM, guettli wrote: > > > Am Mittwoch, 16. August 2017 13:39:53 UTC+2 schrieb Vijay

Re: please help me about django error that encoding is wrong

2017-08-22 Thread Vijay Khemlani
What is the hostname of your machine? If you are using Windows then you can execute "ipconfig /all" on a cmd prompt On Mon, Aug 21, 2017 at 11:27 PM, 輝夜三日月 wrote: > >

Re: Deploy app under subdirectory

2017-08-28 Thread Vijay Khemlani
If possible try and run as a subdomain myapp.mydomain.com it is easier to configure things in that case On Sun, Aug 27, 2017 at 11:39 PM, Angel Ruiz wrote: > Hello everybody, I need run my app under subdirectory, e.g. > mydomain.com/myapp > > I have one app running with Nginx and Gunicorn in U

Re: how to write APIview to access a specific item by using APIViews only

2017-09-05 Thread Vijay Khemlani
To retrieve a particular object in your API you should implement it in a method called "retrieve", not "get", if I remember correctly On Tue, Sep 5, 2017 at 10:28 AM, Rakhee Menon wrote: > CODE: > > class FormList(APIView): > def get(self, request, id): > import ipdb;ipdb.set_trace() > item_obj

Re: Email validation in form

2017-09-12 Thread Vijay Khemlani
"asdf@asdf" is not a valid email so form.is_valid returns False and form.save is never called On Tue, Sep 12, 2017 at 4:52 AM, Moreplavec wrote: > Greetings, > > i have strange problem with my model form. I have simple form for taking > orders, model looks like: > > class Order(models.Model):

Re: Email validation in form

2017-09-12 Thread Vijay Khemlani
erstand, but why while using model form it's not cought by form > itself same as missing or incorect field like "asdf" for email? This is my > problem. I need to show error and not to try to save :) > > > > Dne úterý 12. září 2017 12:47:16 UTC+2 Vijay Khemlani nap

Re: make a button element outside be on the right side of another element inside

2017-09-28 Thread Vijay Khemlani
An input with type "button" instead of "submit" should not trigger the form submit. On Thu, Sep 28, 2017 at 7:56 PM, fábio andrews rocha marques < fabioandrewsrochamarq...@gmail.com> wrote: > In my template, I have a form. This form has a lot of textfields and a > submit button. There's another b

Re: help with my signup api

2020-05-13 Thread Vijay Khemlani
in your code data is json.dumps(request.data), which is a string representation of the json dictionary so data is a str and then you are trying to do item assignment to it On Wed, May 13, 2020 at 8:05 AM ola neat wrote: > good day guys, please i need help with my signup api, when the user click

Re: Passing parameters / attributes to javascript in a template

2015-08-04 Thread Vijay Khemlani
Have you checked the HTML that is actually rendered by the Django template? On Tue, Aug 4, 2015 at 10:39 AM, Déborah Leder wrote: > Hello Larry, thank you for your response. > > I didn't run the debugger, but i know that my values are correctly passed > in the template (when it it outside of the

Re: Django 1.6.11 model class query

2015-08-19 Thread Vijay Khemlani
I'm guessing Django does not update all of the fields of the instance when saving it, only the id On Wed, Aug 19, 2015 at 11:31 AM, Nikunj Badjatya wrote: > Also, > When the same object is retrieved using > > > print(Test.objects.get(id=row.id).uuid) # Prints uuid. > > > > -- > You received thi

Re: Integrating RabbitMQ with Django

2015-09-16 Thread Vijay Khemlani
Celery would be the usual choice for this, why is it not an option? Seems far easier and more stable than trying to use a webserver as a queue worker. On Wed, Sep 16, 2015 at 10:22 AM, Erol Merdanović wrote: > Hi all > > I'm using Django to develop a service. Service connects to RabbitMQ and > r

Re: Integrating RabbitMQ with Django

2015-09-16 Thread Vijay Khemlani
> 2. Celery uses custom queues > > Is this correct? > > On Wednesday, 16 September 2015 15:28:33 UTC+2, Vijay Khemlani wrote: >> >> Celery would be the usual choice for this, why is it not an option? Seems >> far easier and more stable than trying to use a webserver as

Re: Best way to trigger javascript function when returning a page from django view

2015-09-20 Thread Vijay Khemlani
"It's true that when it's not filled correctly, the form returns the validation but we have cases in which the data in the fields is not returned when the form operation is not successful." What cases? Dynamic fields or something like that? Django forms are supposed to pre-fill all the fields when

Re: [newbie] import error after restart (virtualenv)

2015-09-20 Thread Vijay Khemlani
Aren't tests supposed to run with "python manage.py test lists"? On Fri, Sep 18, 2015 at 8:55 PM, David wrote: > Dear Django experts, > > I am reading through Harry Percival's "Test-Driven Development with > Python". > > As I finished chapter 3 yesterday, I was fully on track, perfectly > aligne

Re: Django was present in FSD in Costa Rica

2015-09-21 Thread Vijay Khemlani
Felicitaciones desde Chile también, y espero que más gente por allá se interese en el framework :) On Mon, Sep 21, 2015 at 5:26 PM, Rafael E. Ferrero wrote: > BUENÍSIMO LUIS!!! EXCELENTE INICIATIVA!!! > > Muchos exitos para tí y para Django en Costa Rica > > Saludos, Rafael Ferrero (desde Argent

Re: Method call at end of Django session

2015-10-02 Thread Vijay Khemlani
Also it is most likely inconsistent if the user has the same webpage opened on two different tabs On Fri, Oct 2, 2015 at 5:55 PM, Andreas Kuhne wrote: > Hi, > > I don't think you can reliably do that. Django never knows when the user > closes his browser window. Because a session is stateless (t

Re: KeyError

2015-10-07 Thread Vijay Khemlani
"is_valid" is a method, you should call if user_form.is_valid(): ... On Wed, Oct 7, 2015 at 2:14 PM, Benjamin Smith wrote: > I am making a registration form to register new users using the User model. > > This is the forms.py: > > class UserForm(forms.ModelForm): > confirm_email = forms

Re: Reverse access model through a “double” ForeignKey

2015-10-14 Thread Vijay Khemlani
Value.objects.filter(grouping__build=your_build) I guess You can add it as a method to the Build class On Wed, Oct 14, 2015 at 6:11 AM, Gergely Polonkai wrote: > Hello, > > I have three models: > > • Build > • BuildGrouping, with a ForeignKey “build” pointing to Build > • Value, with a ForeignK

Re: Cron Job

2015-10-14 Thread Vijay Khemlani
The easiest way would be using a custom management command https://docs.djangoproject.com/en/1.8/howto/custom-management-commands/ On Wed, Oct 14, 2015 at 10:53 AM, 'Chris Norman' via Django users < django-users@googlegroups.com> wrote: > Hi again, > I would like to set up a cron job to email th

Re: Question about Django Tutorial Part 5

2015-10-15 Thread Vijay Khemlani
The "create" method (as in Question.objects.create) saves the object to the database On Thu, Oct 15, 2015 at 6:08 AM, Shun Liang wrote: > Dear All, > > In the 5th part of the Django Tutorial ( > https://docs.djangoproject.com/en/1.8/intro/tutorial05/#testing-our-new-view > ), there is a helper f

Re: Issues with django-storages and gunicorn processes

2015-10-22 Thread Vijay Khemlani
Media Library? I'm not aware of something like that in django-storages On Wed, Oct 21, 2015 at 5:22 PM, Mike Herring wrote: > I am using django-storages to store media files in Amazon S3. > > Gunicorn spaws three worker processes, each running their own copy of > S3BotoStorage. When I go into fi

Re: How do I let forms.models.ModelChoiceField.queryset relate on request.user?

2015-11-02 Thread Vijay Khemlani
At least what I do in those cases is to add a constructor (__init__) to the form class which takes the user as a parameter, modify the choicefield queryset, and then call the original constructor of the form. On Sun, Nov 1, 2015 at 3:50 PM, Axel Rau wrote: > User should see only choices related

Re: How to clean up character database fields with leading and trailing spaces

2015-11-03 Thread Vijay Khemlani
As far as I know the Django ORM encapsulates SQL queries, so you can't put arbitrary python code in there (".strip()") If I remember correctly SQL does not have a standard TRIM method, but individual database engines do, for example for Postgres http://www.postgresql.org/docs/9.1/static/functions

Re: Duplicated queries

2015-11-07 Thread Vijay Khemlani
duplicated queries as in exactly the same or with different parameters? If they hace different parameters it sounds like something you can resolve with select_related https://docs.djangoproject.com/en/1.8/ref/models/querysets/#select-related Either way, you would need to post you rmodels and quer

Re: DoesNotExist: Group matching query does not exist.

2015-11-11 Thread Vijay Khemlani
It seems you don't have any groups in your database with the name "test" On Wed, Nov 11, 2015 at 7:14 PM, Robin Fourcade wrote: > Hi, > I'm working with the auth library. > > I've imported all of these: > > from django.shortcuts import render, redirect > from pizza_club_order.forms import * > fr

Re: I'm missing something with Models and database migrations

2015-12-22 Thread Vijay Khemlani
You have two pairs of fields with the same name (line_item_id and invoice_id), what are you trying to do exactly? Why the IntegerFields? In a Many To Many relation the columns are added to a third table between the models. On Tue, Dec 22, 2015 at 9:20 PM, Michael Molloy wrote: > Python 3.3 and

Re: I'm missing something with Models and database migrations

2015-12-23 Thread Vijay Khemlani
. >>> >>> So, in the list of tables (now that I know what I'm looking for), I see >>> a table called invoice_line_items_xref_invoice_id and another called >>> invoice_line_items_xref_line_item_id. Those must be the two tables that >>> Django created to

Re: How to serve a static file with django?

2015-12-23 Thread Vijay Khemlani
I guess the URL would be something like this 127.0.0.1:8000/static/my_app/hello.html (without the first "my_app") assuming your STATIC_URL is '/static/' On Wed, Dec 23, 2015 at 1:57 AM, Dan Bikle wrote: > *Hi List,* > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >

Re: Fitering on manytomany field whose results are contained within another set...

2015-12-23 Thread Vijay Khemlani
You should be able to query it as a ForeignKey Jobs.objects.filter(names__is_a_problem=True).distinct() (distinct to prevent repeated jobs with more than one worker problem) On Wed, Dec 23, 2015 at 9:31 AM, Jonty Needham wrote: > I have a model of the form: > > class Jobs(models.Model): >

Re: ModelForm.is_valid() doesn't work the first time but does the second

2016-01-02 Thread Vijay Khemlani
"First, why does uf.is_valid() return" because you called "uf.is_valid" (note the lack of parenthesis), that's just a reference to the method and does not call it. "Second, why does uf.save() return that stacktrace the first time I call it, but the second time I call it, the object saves? " As f

Re: ModelForm.is_valid() doesn't work the first time but does the second

2016-01-03 Thread Vijay Khemlani
g, but it doesn't work. Note > the code below. is_bound = False if I use instance=u. If I just pass the > Users instance without the 'instance' keyword, is_bound returns True. > > >>> u = Users() > > >>> u.email = 'je...@home.net' > >

Re: hello. get_queryset question

2016-01-03 Thread Vijay Khemlani
Try with self.request.GET['name'] On Sun, Jan 3, 2016 at 11:22 PM, Víctor Suárez wrote: > Hello all, > as it's my first post, if any django developer around, nice work! I > appreciate the package, I've been able to pull a small project I had in > mind for long, very easily with this. > > I am n

Re: why cannot delete attribute id of model?

2016-01-11 Thread Vijay Khemlani
I usually do product.id = None product.pk = None But I'm not sure whether that's the best way to do it On Mon, Jan 11, 2016 at 4:25 AM, Xudong Zhang wrote: > I want to delete the id attribute of a model but failed, it comlains that > the model has no attribute 'id'. But I use hasattr() checked

Re: why cannot delete attribute id of model?

2016-01-11 Thread Vijay Khemlani
At least I use it as part of the process to save a copy of an existing model instance On Mon, Jan 11, 2016 at 9:35 AM, Tony Flury wrote: > Why do you want to delete the id field. The idea of a primary key field is > central to relational databases. If you to suppress the automatically > generate

Re: How to view the generated SQL for test models?

2016-01-16 Thread Vijay Khemlani
At least to me it doesn't make a lot of sense to define new models in your tests, but I also don't know the particular problem you are solving. On Sat, Jan 16, 2016 at 1:27 PM, Brutus Schraiber wrote: > Wrong place to ask such things? > > This doesn't seem too uncommon or complicated, or am I mi

Re: Setting up Django

2016-01-16 Thread Vijay Khemlani
your app is called "generator", that's all you need to put in INSTALLED APPS also, I'm not sure if this matters, but I tend to put my apps after the ones bundled with django. On Sat, Jan 16, 2016 at 5:30 PM, ofeyofey wrote: > Hi, > > I am following the Django tutorial on the Django site. Gettin

Re: De Morgan's Law and QuerySet semantics

2016-02-13 Thread Vijay Khemlani
assert test_obj not in TestObj.objects.filter(Q(m2ms__int_value=10) & Q(m2ms__char_value='bar')) Why shouldn't test_obj be in that query result? test_obj has a m2m with int_value 10 and a m2m (although another one) with char_value bar On Sat, Feb 13, 2016 at 7:45 PM, Lucas Wiman wrote: > I'm wo

Re: Relations one-to-many on django

2016-02-23 Thread Vijay Khemlani
Each product is only associated with one category, so you can only do produto.categoria If you want to iterate over all categories, and then through the products of each category, you could do {% for categoria in categorias %} {% for produto in categoria.produto_set.all %} do comething with prod

Re: context dictionary

2016-02-24 Thread Vijay Khemlani
Django 'is' a framework, therefore you have the flexibility to create your context as you see fit. You could call an external API, query your database, obtain results from ElasticSearch, parse another webpage, or anything that suits the needs of your particular project. It completely depends on th

Re: Can't Get ListView to display result of SQL Query onto Custom Template

2016-02-25 Thread Vijay Khemlani
{{ codelist.arrow }} shouldn't you be using the for variable? something like {{ i.arrow }} On Thu, Feb 25, 2016 at 11:19 AM, Malik Rumi wrote: > *Note- This question was originally posted on SO before I completely > understood what my issue was. However, since editing it to reflect the true

Re: Encoding problem (Postgres)

2016-03-05 Thread Vijay Khemlani
The error you are seeing is at the application level, not database, so I don't think postgres is at fault. Post the full stack trace for the error and the relevant part of your code when it fails. On Sat, Mar 5, 2016 at 3:28 PM, Georges H wrote: > Hi to all the Django community ! > > I started

Re: Encoding problem (Postgres)

2016-03-06 Thread Vijay Khemlani
t I solved this little problem by adding at the top of my > models.py: > > django.utils.encoding import from python_2_unicode_compatible > > > And always in models.py before each class: > > @ python_2_unicode_compatible > > Perfect! > > Le dimanche 6 mars 2016

Re: ¿Como hacer mi primera aplicacion con Django en Ubuntu? ¿How Can I make my first project with Django?

2016-04-03 Thread Vijay Khemlani
Leiste el tutorial? https://docs.djangoproject.com/en/1.9/intro/tutorial01/ On Sat, Apr 2, 2016 at 3:25 AM, Kike Martinez wrote: > Hola quisiera saber como puedo hacer un proyecto con Djando desde cero > gracias > > -- > You received this message because you are subscribed to the Google Groups

Re: Problems with dumpdata/loaddata

2016-04-06 Thread Vijay Khemlani
Your apps are called members and posts, or those are the names of the models? On Wed, Apr 6, 2016 at 9:20 AM, ludovic coues wrote: > Both error look like encoding error. > In the JS file, it look like there is a byte order mark at the start > of the file. > The first line of both file might help

Re: Any Django users based in Chile?

2016-04-07 Thread Vijay Khemlani
Chilean Django dev here We are not many, but at least there are plenty of Python developers here. Regards! On Thu, Apr 7, 2016 at 12:24 PM, John wrote: > Curious to connect with Django devs in Chile. > > Hoping to do a Django project with Chilean devs in the coming months and > would love to c

Re: Simple to say but difficult in django?

2016-04-09 Thread Vijay Khemlani
Your question seems to be incomplete considering you are using a login_required decorator then you also want to limit access to the file If you put it in your static directory then it will be public if anyone knows the URL to the file On Sat, Apr 9, 2016 at 1:56 PM, Luca Brandi wrote: > Hi, >

Re: No Downtime Code Releases

2016-04-19 Thread Vijay Khemlani
Also, you don't need to restart Apache / nginx or whatever, or delete the pyc files, just reload uwsgi / gunicorn. On Tue, Apr 19, 2016 at 6:48 PM, Avraham Serour wrote: > you can easily do code reloading with uwsgi graceful reload, no user will > ever know you reloaded your application, no need

Re: Can not read request.body from a POST request

2016-04-20 Thread Vijay Khemlani
Why would you want to access request.body directly? You should use request.POST, request.GET, request.FILES. On Wed, Apr 20, 2016 at 5:27 PM, Mihai Corciu wrote: > Is there a method to access request.body from a POST request in Django, > without disabling 'django.middleware.csrf.CsrfViewMiddlewa

Re: Can not read request.body from a POST request

2016-04-21 Thread Vijay Khemlani
aign=chrome_ext> > > > > > Gergely Polonkai > [image: https://]about.me/gergely.polonkai > > <https://about.me/gergely.polonkai?promo=email_sig&utm_source=email_sig&utm_medium=email_sig&utm_campaign=external_links> > > 2016-04-20 22:44 GMT+0

Re: Passing Django Template Vars to JS

2018-06-10 Thread Vijay Khemlani
I'm not sure why your code does not work (maybe there is a "race condition" between the JS click handlers), but that global variable is a bad idea in general. You can add the comment ID as an attribute to your button, like and in your event handler obtain the comment id $("#like_comment_button

Re: Interfaz administrativa, login con SSH

2018-06-10 Thread Vijay Khemlani
En general SSH sirve para hacer conexiones remotas por terminal (bueno, puedes hacer una sesión X a través de SSH pero no creo que sea lo que necesites) La forma más común de aumentar la seguridad del login es por two factor authorization, básicamente mandar una validación a tu celular o algun otr

Re: Interfaz administrativa, login con SSH

2018-06-11 Thread Vijay Khemlani
"Vijay, thanks for the help, but the authentication of two factors seems quite uncomfortable, considering that an administrator can enter every day, several times a day, having to depend on a mobile device for each login. " Session cookies last for 2 weeks by default in Django, regardless of the l

Re: Interfaz administrativa, login con SSH

2018-06-12 Thread Vijay Khemlani
La máxima seguridad (razonable) sería conectarse a una VPN y que el admin de Django solo acepte logins desde dentro de la VPN, pero para el 99% de los casos suena innecesario. Para abrir un navegador dentro del servidor mismo tendrías que tener instalado todo ambiente de escritorio en el servidor

Re: Nested for loops in templates

2018-06-13 Thread Vijay Khemlani
As far as I know you can't do it directly in the templating system Yo could write a template tag as described here https://stackoverflow.com/questions/2894365/use-variable-as-dictionary-key-in-django-template/10700142#10700142 or use a different data structure, for example each row as a list of

Re: A few doubts with an implementation.

2018-07-02 Thread Vijay Khemlani
You can also use PubNub (https://www.pubnub.com/) or similar services On Mon, Jul 2, 2018 at 10:29 AM Vineeth Sagar wrote: > Mikhailo Keda wrote: >> >> to fetch emails every N minutes or hours - >> http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html >> I want the user to

Re: Use an external REST API in django admin

2018-07-16 Thread Vijay Khemlani
django rest framework would be your best bet http://www.django-rest-framework.org/ On Mon, Jul 16, 2018 at 10:16 AM micka wrote: > Hello, > > I wish I could use the data from an external API in the administration of > Django. I wish I could list, read, edit and create objects but instead of > u

Re: Django performance issue that's troubling

2018-08-23 Thread Vijay Khemlani
Maybe your update form has a field related to a model with thousands of records? like rendering a select combo box with thousands of choices? On Thu, Aug 23, 2018 at 5:30 PM Jim Illback wrote: > I have a Django app in development that performed perfectly with about 20 > client records. Each clie

Re: Django performance issue that's troubling

2018-08-24 Thread Vijay Khemlani
; 1. Override the get query set method to only pass in the single record - > will that work? > 2. I’ve been trying to show the field in a tag and override the View’s > post method by aftering is_valid(), but it always returns invalid > expression errors. > > What am I missing? >

Re: Django performance issue that's troubling

2018-08-24 Thread Vijay Khemlani
uired field. If I add it to the form, > Django has to allow all potential update values to be shown. What’s the way > out of this mess? > > Thanks, > Jim > > > Begin forwarded message: > > *From: *Vijay Khemlani > *Subject: **Re: Django performance issue that's t

Re: A questionale developer had added exraneous code to image URLS that used to work. I would be gratefuldor your assitamce please?

2018-09-09 Thread Vijay Khemlani
If you're using django-storages with S3 as the media backend then there is a setting called AWS_S3_FILE_OVERWRITE that prevents files with the same name form being uploaded. In those cases the library appends a suffix similar to your example. Usually this is useful to prevent files from being over

Re: "Project object has no attribute review_set"

2018-10-12 Thread Vijay Khemlani
Since the related name in the project foreign key is "review" you have to use that keyword for the related query from project, so it should be "self.review.all()" instead of "self.review_set.all()" in your Project methods. Regards! On Fri, Oct 12, 2018 at 9:25 AM Melissa Malala wrote: > Getting

Re: error in models

2019-08-05 Thread Vijay Khemlani
Remove the quotes On Mon, Aug 5, 2019 at 11:24 AM Mudasir Mian wrote: > Dear Team, > im facing this error in models > help me please > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emai

<    1   2   3   4