Migration Issues when updating model's default primary key from id to uuid

2017-11-10 Thread Liuyang Wan
Let's say in my Django project I have two models A and B. class A(models.Model): something... class B(models.Model): a = models.ForeignKey(A) Later on I decided to use uuid as the primary key value. so I update the models: import uuid class A(models.Model): id = models.UUIDField(

Re: Django Templates and Conditional CSS classes

2017-11-10 Thread treyd
Thanks, all, for the info. Looks like the best way to clean this up is to make the model have some knowledge of the CSS class I want to use and make a method to get it. I like that, but I was unsure about sticking view information into the model. Probably the best solution is javascript logic

Re: Django Templates and Conditional CSS classes

2017-11-10 Thread Vijay Khemlani
You can also add a "state_css_class" (or something) method to your object class and just call ... the method should be quite simple On Fri, Nov 10, 2017 at 7:01 PM, Adam Simon wrote: > > You can pass the class from either the model or the view into the > template. For example, you can assign

Re: Django Templates and Conditional CSS classes

2017-11-10 Thread Adam Simon
You can pass the class from either the model or the view into the template. For example, you can assign a class to a button with a variable: <|button> And then the class would have to be defined in your style somewhere On Fri, Nov 10, 2017 at 1:37 PM treyd wrote: > At some point I plan on fig

Re: Django Templates and Conditional CSS classes

2017-11-10 Thread treyd
At some point I plan on figuring out how to do more intelligent front-end in-browser stuff (Angular, etc) which yeah would definitely help me here but I was wondering if there was a Django-only way of doing this. On Friday, November 10, 2017 at 3:51:09 PM UTC-5, Adam wrote: > > > Are you open to

Re: Django Templates and Conditional CSS classes

2017-11-10 Thread Adam Simon
Are you open to using JavaScript in the front end? It would make it really easy On Fri, Nov 10, 2017 at 12:40 PM treyd wrote: > Hello, > > I am trying to render a model field in a django template, and, based on > the value of the field, I want to specify a different CSS class. Right > now, my s

Django Templates and Conditional CSS classes

2017-11-10 Thread treyd
Hello, I am trying to render a model field in a django template, and, based on the value of the field, I want to specify a different CSS class. Right now, my solution is this: {{ myobject.state }} This works, but seems like a really ugly solution and a bunch of logic in the template. Is the

Re: Django raising error - hostname doesnot match.

2017-11-10 Thread Rahul Paul
Thanks James for your suggestion. So according to you, I must use the domain name and not the IP address anymore in my request. Thanks again. On Friday, November 10, 2017 at 11:09:59 PM UTC+5:30, James Schneider wrote: > > > > On Nov 10, 2017 3:45 AM, "Rahul Paul" > > wrote: > > Hi, > > I am us

Re: Django raising error - hostname doesnot match.

2017-11-10 Thread James Schneider
On Nov 10, 2017 3:45 AM, "Rahul Paul" wrote: Hi, I am using requests package to send a post request to an API within my application. I am using the request as : *requests.post("https://xx.xxx.xxx.xxx/my-admin/api/api2 ", data=data)* where "xx.xxx.xxx.

Re: Seeking design guidance on a Team model where a user sends invitation to other users to join the team

2017-11-10 Thread Adam
Weird, I dont see our conversation, Anyway here is a simple setup: urls.py: from django.conf.urls import url from .views import ajax_comment_send urlpatterns = [ url("comment_send", ajax_comment_send, name="comment_send"), ] then a view - this is from my project, you will to make c

Re: WSGI Steps and Sequence ... django.setup() reduces latency?

2017-11-10 Thread Etienne Robillard
Hi, Le 2017-11-10 à 08:50, guettli a écrit : AFAIK django.setup() gets done implicit for web requests, you only need to call it for scripts. What do you mean with "when django.setup() is disabled"? But maybe in my code base something works different than in standard django. Up to now I

RE: Error in django 1.8.7 version with python 2.7.12

2017-11-10 Thread Matthew Pava
It looks like you’re running it in Python 3, not Python 2.7.12. I would start looking there. From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Ankush Chauhan Sent: Friday, November 10, 2017 4:35 AM To: Django users Subject: Error in django 1.8.7 version wi

Re: WSGI Steps and Sequence ... django.setup() reduces latency?

2017-11-10 Thread guettli
Am Dienstag, 7. November 2017 09:55:34 UTC+1 schrieb Etienne Robillard: > > Hi, > > I don't initialize django.setup() at runtime but when modules are loading. > I have not observed any latency issues when django.setup() is disabled. > > > AFAIK django.setup() gets done implicit for web requests

Re: [django channels] unrecognized arguments: --noworker

2017-11-10 Thread mccc
nevermind, sorry about the spam: I had an old django-channels installation polluting my environment - I found out while gathering my libraries versions to post here... On Friday, November 10, 2017 at 2:05:29 PM UTC+1, mccc wrote: > > Hello, > > I'm trying out channels, but I'm getting an "unreco

[django channels] unrecognized arguments: --noworker

2017-11-10 Thread mccc
Hello, I'm trying out channels, but I'm getting an "unrecognized arguments: --noworker" error when trying to execute a very simple "python manage.py runserver --noworker". I found this file in the repository

Re: Django raising error - hostname doesnot match.

2017-11-10 Thread Rahul Paul
In some place I wrote that "However the very same API is returning proper result with both --- IP address and domain name". I would like to correct hat this scenario is working when I am hitting the API from POSTMAN. On Friday, November 10, 2017 at 5:15:20 PM UTC+5:30, Rahul Paul wrote: > > Hi,

Error in django 1.8.7 version with python 2.7.12

2017-11-10 Thread Ankush Chauhan
I am getting the following trackback error message when I run command(python manage.py runserver) on ubuntu OS: Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/usr/lib/python3/dist-packages/django/core/management/__init__.py",

Django raising error - hostname doesnot match.

2017-11-10 Thread Rahul Paul
Hi, I am using requests package to send a post request to an API within my application. I am using the request as : *requests.post("https://xx.xxx.xxx.xxx/my-admin/api/api2";, data=data)* where "xx.xxx.xxx.xxx" is the IP of my server on which this API is hosted. When I am trying to call thi