Django formfield_for_foreignkey

2014-10-29 Thread Cristian Vargas
As i stated in this question i am trying to follow something like this example . Basically i am tryin

Re: Rendering TabuarInline inside ModelAdmin without a foreign key

2014-10-29 Thread Mario Gudelj
Here's the models code, DR: class CRMUser(AbstractBaseUser, PermissionsMixin): email = models.EmailField( verbose_name='Email Address', max_length=255, unique=True, ) first_name = models.CharField("First Name", max_length=50, blank=True) last_name = models.C

Re: Slow SQL query

2014-10-29 Thread Erik Cederstrand
> Den 29/10/2014 kl. 18.15 skrev Collin Anderson : > > Right, in practice it should be less than 1000 returned rows. > > I've changed the code to run the query without the status != 4 clause, and > manually filtering that out using python, because, yes, 97% of the rows are > status != 4. Or may

Re: DB foreign key constraints : Django 1.7 regression ?

2014-10-29 Thread Carl Meyer
Hi NotSqrt, On 10/29/2014 11:53 AM, nots...@gmail.com wrote: > Just tested the following: > > * create clean DB > * run syncdb > * compare obtained tables when using Django 1.6.8 and Django 1.7.1 > > My findings : > > In Django 1.7, some fields with models.ForeignKey no longer get the DB

Re: What is the purpose of the include function?

2014-10-29 Thread Carl Meyer
Hi Ben & Daniel, On 10/29/2014 07:41 AM, Ben Lopatin wrote: > Hi Daniel, in this case I would think the latter would fail - the > `include` function loads a URL conf module and then finds the > `urlpatterns` attribute, whereas `admin.site.urls` is a class method > that dynamically builds a list of

Re: Rendering TabuarInline inside ModelAdmin without a foreign key

2014-10-29 Thread Mario Gudelj
I did not produce the original model so I wouldn't know. My thinking is that the order model had to be independent of the user model so that the deletion of the user doesn't cascade down to orders. It's a mezzanine site and that's how it handles fk from orders to users. On 29/10/2014 9:27 pm, "Dani

Re: Do you think Django's future is threatened by JS frameworks in both client & server?

2014-10-29 Thread Javier Guerra Giraldez
On Wed, Oct 29, 2014 at 1:11 PM, Glen Jungels wrote: > the javascript frameworks (Node, Angular, etc) differ in that the execution > is done client side Node.js is a server framework. -- Javier -- You received this message because you are subscribed to the Google Groups "Django users" group

Re: Charfield case insensitive sorting in Model Admin

2014-10-29 Thread Collin Anderson
Hello, One way to do it would be to have add an editable=False field name_sort that's a lower() version of your name field. You can update that field in the save method. In the admin, you can tell it to order by name_sort using admin_order_field. Collin -- You received this message because y

Re: Dictionary passed to widget attr gets mutated

2014-10-29 Thread Collin Anderson
You could do this: class FormWithoutBug(forms.Form): attrs = {'type':'time', 'required':'true'} session_start = forms.TimeField(widget=forms.TimeInput(attrs=attrs.copy())) session_end = forms.TimeField(widget=forms.TimeInput(attrs=attrs.copy())) -- You received this message because

Re: Dictionary passed to widget attr gets mutated

2014-10-29 Thread Collin Anderson
Hello, Interesting. Sounds like something that could be documented. Collin -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroup

Re: how to save in inline form total sum

2014-10-29 Thread Collin Anderson
Hello, the only problem that is save correct total sum but a hit 2 o 3 time button > save in the admin, not first time > why? i don't know :( It's probably because ModelA is saved before the individual ModelB's. You could calculate this _after_ the ModelB inlines(?) have been saved using the

Re: Generating a list of available templates

2014-10-29 Thread Collin Anderson
Hi William, > for loader in settings.TEMPLATE_LOADERS: > loader_module = > importlib.import_module('.'.join(loader.split('.')[:-1])) > print '\n'.join(source for source in > loader_module.Loader().get_template_sources('')) > You could also get the loader like this: from django.templa

Re: pre-populate tabular inline in admin

2014-10-29 Thread Collin Anderson
Hello, This one's tricky. It may be simplest to just _create_ the empty inline ModelA's so they appear. Otherwise, you'll need to look at the ModelA's that exist in the database and figure out which ones needed to be added to the initial data. You'll likely need to add the initial data using t

Re: Do you think Django's future is threatened by JS frameworks in both client & server?

2014-10-29 Thread Glen Jungels
I have to agree that debugging javascript does stink. However, the javascript frameworks (Node, Angular, etc) differ in that the execution is done client side whereas for Django, any PHP framework and Microsoft ASP/C#, the execution is backend on the web server. Depending on the circumstance, the

Django query in DetailView

2014-10-29 Thread Ronaldo Bahia
*This question is also in http://stackoverflow.com/questions/26635406/django-query-in-detailview I have DetailVIew wich returns a list of related objects (m2m throught). It works just fine! But I need to search for objects'names and it is returning all objects instead of only the related ones.

Re: Do you think Django's future is threatened by JS frameworks in both client & server?

2014-10-29 Thread Chris Hawkes
As a business owner and full time Developer using C# and Visual Studio I do all of my website building at home in Django. It's an amazing framework that is far above anything else I've tried which includes, ASP, Node.js, CodeIgniter, Yii and any other Python frameworks out there. (I'll admit

DB foreign key constraints : Django 1.7 regression ?

2014-10-29 Thread notsqrt
Hi ! Just tested the following: - create clean DB - run syncdb - compare obtained tables when using Django 1.6.8 and Django 1.7.1 My findings : In Django 1.7, some fields with models.ForeignKey no longer get the DB constraint. In Django 1.6, I indeed get (in postgresql) for instance:

Re: Error was: No module named 'django.db.backends.pymysql'

2014-10-29 Thread Collin Anderson
Hello, In your settings.py (or somewhere early in the code), run this: import pymysql pymysql.install_as_MySQLdb() Then, set your BACKEND to django.db.backends.mysql. Or, better yet, install https://github.com/PyMySQL/mysqlclient-python as that is our recommended choice for using MySQL with Dj

Re: Django model help text into database comment field

2014-10-29 Thread Collin Anderson
Hi Phillipe, You'll likely need to run the SQL to update the comment by hand. You can get the data from your models like this: for field in MyModel._meta.fields: print field.attname, field.help_text Collin -- You received this message because you are subscribed to the Google Groups "Djan

Re: Slow SQL query

2014-10-29 Thread Collin Anderson
Hi Erik, > Ok, you're not giving much of a chance to the query planner either. The > cardinality of status is 10, so status!=4 potentially means "give me 90% of > the rows". The cardinality of user_id is a mere 12, which potentially means > "give me 8% of the rows". Your query could easily re

Deploy with wsgi causes python library to fail.

2014-10-29 Thread Bohdan Anderson
I can run in the testing server fine (python manage.py runserver 0.0.0.0:8000) but once I deploy to the server I'm not even getting the django error page in response to it's failure. I looked into the apache log files and all I get is a generic error message "[notice] child pid 17364 exit signal

"Raw query must include the primary key" when inheriting models

2014-10-29 Thread Tobias Wolff
Hi, I have created two models as this: | classCampaign(models.Model): name =models.CharField(max_length=255) classCampaignExt(Campaign): status =models.IntegerField() | In my APIView I do this: | defget(self,request,campaign_id,response_format=None): campaigns =CampaignExt.ob

Re: rapidsms

2014-10-29 Thread Mark Phillips
1. Perhaps reading the RapidSMS tutorial will help http://rapidsms.readthedocs.org/en/develop/tutorial/index.html. 2. Join the RapidSMS Google group and ask questions there. Mark On Wed, Oct 29, 2014 at 6:27 AM, ngangsia akumbo wrote: > I just got a new project to build an sms app to be

Re: Database field for Image Upload

2014-10-29 Thread Bill Freeman
Note that if these images will be displayed on the site it is best done by your front end (Apache, ngnx, etc.) since the HTML to show them treats them as a separate request, and serving static files is your front end's forte. The front end knows how to do this with files, but probably not with data

Re: What is the purpose of the include function?

2014-10-29 Thread Ben Lopatin
Hi Daniel, in this case I would think the latter would fail - the `include` function loads a URL conf module and then finds the `urlpatterns` attribute, whereas `admin.site.urls` is a class method that dynamically builds a list of URL patterns based on your installed apps. There's nothing to im

rapidsms

2014-10-29 Thread ngangsia akumbo
I just got a new project to build an sms app to be used to communicate within a particular group of people.. I intend to use rapidsms . I dont even now how much to ask them. This is my first contract as a python programmer. Any ideas ??? -- You received this message because you are subscribed

Re: Database field for Image Upload

2014-10-29 Thread pjotr
https://docs.djangoproject.com/en/1.7/ref/models/fields/#imagefield The image file will not be stored in the database, but in MEDIAROOT by default. So maybe this is not the answer to your question. On Wednesday, October 29, 2014 10:18:30 AM UTC+1, Shubham Gupta wrote: > > Is there any way from

Smart locale fallback

2014-10-29 Thread Malte Beckmann
We got a standard locale fallback to "en" if the browser language is not supported by our site. However, it would make sense to fallback from en_AU to en_UK rather than to en which is essentially en_US. Or zh_hans to zh_CN which are essentially the same. I am sure this can be done but I doubt

Database field for Image Upload

2014-10-29 Thread Shubham Gupta
Is there any way from which i can add image as a field so that images are added into my database? what data type i must use for this problem..? thank you in advance -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this grou

Charfield case insensitive sorting in Model Admin

2014-10-29 Thread Azam Alias
Hi, I am using Django 1.7 on Python 3.4 and quite new to both Django and Python. I would like to sort a name field (Charfield) in ModelAdmin view in case-insensitive way. The default sorting is case-sensitive. How could I sort it in case-insensitive? Thanks in advance. -- You received this

Re: Rendering TabuarInline inside ModelAdmin without a foreign key

2014-10-29 Thread Daniel Roseman
On Wednesday, 29 October 2014 03:57:36 UTC, somecallitblues wrote: > > Hi list, > > I have a table of orders where one of the columns is a IntegerField > containing the id of a user who created the order. > > Since it's not a FK field django admin can't display these orders inline > inside the u