excel file upload to MySQL database

2016-01-13 Thread girija sameera
Hello,
  I am  a Django beginner working on a web application wherein I am 
required to provide back-end support. I am expected to take an excel file 
uploaded by the admin from the template , parse the file using available 
Django libraries and upload it to MySQL database . Also  bulk upload of 
files needs to be supported.

I would like some suggestions on how to proceed.I would really appreciate 
links to tutorials and websites.

Thank you,

Girija



 

-- 
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...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/590dc838-43e2-4596-a7b9-93fb9216b9e8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Please help me on generating the ORM query for given SQL query.

2016-01-13 Thread Pramod Bisht
I am unable to generate ORM query for given SQL query. I have posted this 
question on 
stackoverflow at 
http://stackoverflow.com/questions/34745199/django-orm-for-given-group-by-sql-query-with-aggregation-method-sum-and-count

Please help me on that.


Thanks in advance.

-- 
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...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0e3160f6-6118-4d82-8b4e-bb7ea908ed3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Showing BooleanField checkbox on left

2016-01-13 Thread Sayse
 

I'm in the process of trying to minimize the amount of code I need to use 
to render a form with bootstrap styling with the hope of rendering with 
just {{ form }} but I haven't yet managed to find a way to render a 
BooleanField with the checkbox before the text.

 
from django.forms import Form, BooleanField

class MyForm(Form): 
field = BooleanField(label='Test Label') 

MyForm().as_table()

 

The above test code will output 

 
Test Label:

But what I'm hoping to achieve is the same look and feel as shown in the 
bootstrap docs .

 
Test Label:

 The problem in doing this is that the rendering is handled via the form, 
where the label and the field are positioned/rendered separately as shown 
in the source 
, 
, and I have yet to find a place to override that will allow me to render 
the widget inside of the label...

 

Any ideas how I can achieve this?

-- 
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...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c92f9f04-6c72-4d2d-8ff4-6de34be9f00e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: excel file upload to MySQL database

2016-01-13 Thread Larry Martell
On Wed, Jan 13, 2016 at 9:26 AM, girija sameera  wrote:
>
> Hello,
>   I am  a Django beginner working on a web application wherein I am required 
> to provide back-end support. I am expected to take an excel file uploaded by 
> the admin from the template , parse the file using available Django libraries 
> and upload it to MySQL database . Also  bulk upload of files needs to be 
> supported.
>
> I would like some suggestions on how to proceed.I would really appreciate 
> links to tutorials and websites.

This is something you'd typically do on the server side from python.
You can use a lib like openpyxl for that
(https://pypi.python.org/pypi/openpyxl)

-- 
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...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CACwCsY4pRdid9H1_XVrF1mVGfPkOz%2Bs4z1-a1aVmpVb2zZrEzg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: excel file upload to MySQL database

2016-01-13 Thread François Schiettecatte
You can also use xlrd to open .xls files if needed:

https://pypi.python.org/pypi/xlrd

François

> On Jan 13, 2016, at 10:48 AM, Larry Martell  wrote:
> 
> On Wed, Jan 13, 2016 at 9:26 AM, girija sameera  
> wrote:
>> 
>> Hello,
>>  I am  a Django beginner working on a web application wherein I am required 
>> to provide back-end support. I am expected to take an excel file uploaded by 
>> the admin from the template , parse the file using available Django 
>> libraries and upload it to MySQL database . Also  bulk upload of files needs 
>> to be supported.
>> 
>> I would like some suggestions on how to proceed.I would really appreciate 
>> links to tutorials and websites.
> 
> This is something you'd typically do on the server side from python.
> You can use a lib like openpyxl for that
> (https://pypi.python.org/pypi/openpyxl)
> 
> -- 
> 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...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CACwCsY4pRdid9H1_XVrF1mVGfPkOz%2Bs4z1-a1aVmpVb2zZrEzg%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
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...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/57E82E9F-CA4F-4A02-831C-B7014A665A73%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


max_length in form not working

2016-01-13 Thread Ashutosh Singh
Hi,

I am using django 1.8.7. I noticed that max_length for form is not working. 
The form validates even when the max_length is set and password length is 
more than 50 for following code. Though the min_length works fine.


class AuthenticationForm(forms.Form)
:
email_mobile = forms.CharField(widget=forms.TextInput, label="Email or 
Mobile")
password = forms.CharField(widget=forms.PasswordInput, 
label="Password", min_length=6, max_length=50, 
error_messages={'min_length': 'Password should be at least 6 characters 
long.'})
remember_me = forms.BooleanField(widget=forms.CheckboxInput, required = 
False)

def clean(self):
cleaned_data = super(AuthenticationForm, self).clean()
try:
if 'email_mobile' in self.cleaned_data:
int(self.cleaned_data['email_mobile'])
if len(self.cleaned_data['email_mobile']) != 10:
raise forms.ValidationError("Please provide a valid 10 
digit mobile number.")
except (ValueError, TypeError):
if 'email_mobile' in self.cleaned_data:
validate_email(self.cleaned_data['email_mobile'])

return self.cleaned_data

Am I doing something wrong or is it a bug ?

-- 
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...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/12a685d0-d85d-4b76-929b-bc15c5cd847e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


how do I .............?

2016-01-13 Thread Steve Burrus
how do I connmect to the Django server on the command line? 

-- 
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...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bb769cd8-8f1a-41e2-84cb-20e5f026b715%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how do I .............?

2016-01-13 Thread Fred Stluka

python manage.py shell

--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

On 1/13/16 1:43 PM, Steve Burrus wrote:

how do I connmect to the Django server on the command line?
--
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...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bb769cd8-8f1a-41e2-84cb-20e5f026b715%40googlegroups.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56969BC6.4070603%40bristle.com.
For more options, visit https://groups.google.com/d/optout.


Re: apps.populate deadlock

2016-01-13 Thread Shai
Hi,

On Wednesday, January 13, 2016 at 12:54:59 AM UTC+2, John Bazik wrote:
>
> Breaking it down:
>
>- Django.setup wants to load all apps, and calls apps.populate
>- Django-cms plugins register themselves at load time
>- Django-cms plugin registration involves loading templates
>
>
I have never used Django-CMS, but according to your description, it (or its 
plugins) is doing what 
applications should avoid doing since Django 1.7 and the app-loading 
refactor. Registrations which 
involve interactions with applications -- and loading templates falls under 
this definition -- should 
happen only in an app's AppConfig.ready(), after all the models are already 
loaded.
 

>
>- Django-multisite provides a template loader (for per-site templates)
>
>
>- Django-multisite also monkey-patches Sites' cache (normally a dict) 
>with a wrapper around a django cache
>
>
>- The django-multisite template loader fetches the current site from 
>cache when loading template
>
>
Loading templates involves a trivial interaction with apps in the sense 
that apps' template directories
are used as template sources; but it can be deeper, because, as in your 
example, 3rd-party template
loaders may use models for loading them. It can be the site object as here, 
it can even be the
templates themselves stored in the database.
 

>
>- Django's LocMemCache backend fetches a pickled model from cache
>- It is implicitly unpickled by django.db.models.base.Model which 
>calls model_unpickle
>- model_unpickle tests if apps.ready is true and if not, calls 
>apps.populate
>
> I could break the cycle any number of places, but it seems to me that all 
> the apps are doing reasonable things (monkey patching aside), and django 
> shouldn't be calling apps.populate to unpickle a model.  Perhaps that is 
> unavoidable?
>

The question of whether Django should be calling apps.populate() to 
unpickle a model (instance) will
be better discussed on django-developers, but I think that with 
well-behaved apps it is harmless.

HTH,
Shai.

-- 
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...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0ac3f5de-acdd-4acb-8e6f-606413f6d40a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how do I .............?

2016-01-13 Thread Tim Chase
On 2016-01-13 10:43, Steve Burrus wrote:
> how do I connmect to the Django server on the command line? 

You can use a command-line browser:

  lynx http://localhost:8000
  links http://localhost:8000
  elinks http://localhost:8000
  links2 http://localhost:8000
  w3m http://localhost:8000
  edbrowse http://localhost:8000

Most of those take a "-dump" option to format the output HTML as text
and dump it to stdout.

-tkc


-- 
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...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20160113135834.37aa8e17%40bigbox.christie.dr.
For more options, visit https://groups.google.com/d/optout.


Documentation for User.set_unusable_password() doesn't feel complete

2016-01-13 Thread Brice PARENT
When you set an usable password (using 
https://docs.djangoproject.com/en/dev/ref/contrib/auth/#django.contrib.auth.models.User.set_unusable_password),
 
it is not really clear that to make the password usable again, one should 
use `set_password` and define a new one. 
The doc says that this method "Marks the user as having no password set." 
which sounds like it's a boolean attribute somewhere that we might unset 
somehow. It should probably state that the method replaces the active 
password by one that can never be used, and add that to be able to use the 
password, it has to be set again using `set_password`. It also gives the 
false impression that we could prevent temporarily an user from login by 
setting this, but that would be a bad idea as it would lose the password.

Or maybe the method name `set_unusable_password` is explicit enough in 
english, but for other languages, I'm not sure the documentation should 
only rely on the methods names to be understood (the description looks like 
the one for a method that would be called `set_password_unusable`).

What do you think about it?
Thanks

-- 
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...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7d9792fa-f41b-4692-b653-4dd7873d0381%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Concatenate complex views

2016-01-13 Thread Arnab Banerji
Hi - I am trying to concatenate "read-only" form views of all objects 
pertaining to a given model in a single page (I already have a template for 
viewing the form for one object). Given that the forms are reasonably 
complex (in some cases involving formsets), a simple "inclusion tag" 
approach does not work for me (since that requires a simple dictionary). 
Any ideas on what to do here?

Example: a "print all cars" button in a car inventory app, which prints out 
a concatenation of all the car views in the inventory. Eventually, that can 
be exported to a PDF - to be viewed as a comprehensive inventory list.

Thanks!
-AB

-- 
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...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/71d15faf-029f-4412-bfc8-dada465f0727%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Concatenate complex views

2016-01-13 Thread Aaron C. de Bruyn
I may be missing something, but couldn't you use a generic ListView and
something like:

{% for car in car_list %}
  Car Make: 
  ...etc
{% endfor %}

Don't include a  tag or a submit button and you should get something
that looks like a form, but is read-only.
Maybe even disable the input box so it still looks like a normal input box,
but you can't click/type in it.

-A

On Wed, Jan 13, 2016 at 1:37 PM, Arnab Banerji  wrote:

> Hi - I am trying to concatenate "read-only" form views of all objects
> pertaining to a given model in a single page (I already have a template for
> viewing the form for one object). Given that the forms are reasonably
> complex (in some cases involving formsets), a simple "inclusion tag"
> approach does not work for me (since that requires a simple dictionary).
> Any ideas on what to do here?
>
> Example: a "print all cars" button in a car inventory app, which prints
> out a concatenation of all the car views in the inventory. Eventually, that
> can be exported to a PDF - to be viewed as a comprehensive inventory list.
>
> Thanks!
> -AB
>
> --
> 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...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/71d15faf-029f-4412-bfc8-dada465f0727%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEE%2BrGodwfWU2QT%3D8%2B%2Bxvrp8ao0%2BbwkSnArBHMT1L-%3DrfNLuVg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.