Re: Melb Django School Second GO

2015-03-01 Thread David Mutton
Sounds great! I wish I was in Melb rather than Adelaide.


On Monday, 2 March 2015 17:57:35 UTC+10:30, MelbDjango School wrote:

> Hey Guys,
>
> Melb Django & Common Code is starting its second round of free classes on 
> Django. The classes are going to be held fortnightly starting March 12 from 
> 4-6pm. They will be going through the essentials of Django to advance 
> topics. The course will be given by leading Django Developers in the 
> industry. Please bring a laptop and we'll provide the rest. See you in 
> School!
>
> If you have any questions please contact melbdjan...@acommoncreative.com 
> .
>
> Cheers,
> Darren
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c080a033-e5f0-4e29-af54-a1d1ab16bdc3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Wysiwyg and images (Summernote or Froala)

2015-03-01 Thread David Mutton
Hi Sakis,
I did manage to solve this using froala (
https://github.com/froala/django-froala-editor)with a two step process.
1) First I set up my environment with gunicorn as the application server
and nginx serving up /static/* and /media/*

2) When an image is dragged into froala a http request is made to a django
view which uploads the image and returns the path of the image in the form
{link:'path/to/file.png''} by viewing the console (ctrl+shift+j in
chrome)while dragging images into froala I saw that the wrong path was
being returned (a leading / was missing) I edited froala's view.py to
return the correct path. While I was there I also edited it to save file
uploads to the correct location.

On 1 March 2015 at 00:47, Sakis Brouzioutis  wrote:

> Hi Dave,
>
> I encounter the same problem. Did you find any solution?
>
> I really don't know what is going wrong and the image does not appear.
>
> Sakis
>
> Τη Τετάρτη, 4 Φεβρουαρίου 2015 - 12:04:30 π.μ. UTC+2, ο χρήστης David
> Mutton έγραψε:
>
>> Hi,
>> I've been trying to integrate a WYSIWYG editor into my Django project. I
>> first started with Summernote and I had no issue integrating the it into
>> admin or a form. I followed the instructions on their github and everything
>> works great except image uploading and inserting. The file is uploading (I
>> can see it in the filesystem) but it does not show up in the editor or in
>> the resulting html.
>>
>> I thought it was just Summernote and so I switched to Froala but I'm
>> getting the exact same behavior. Is there something I'm missing with image
>> upload inside a wysiwyg?
>>
>>
>> Dave
>>
>>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/jKvMnVPnMjM/unsubscribe.
> To unsubscribe from this group and all its topics, 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a0eb7cff-6423-4f86-b4ac-fea9604e6604%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAm-pDp0t4VtTez0NxqhjXvZjmkJoru0bnhWTF0JjL-vCwYFYw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


django Search page

2015-03-01 Thread Sabeen Sha
 

 which is the best way to implement the following::
i will be having a text box and a Add button

Along with a table below it containing headers class 
AssesmentBuildingDetails(models.Model): 


 numbuildingid1 = models.CharField(max_length=14,unique=True) 

numbuildingid2 = models.CharField(max_length=7,primary_key=True) 

previous_year = models.CharField(max_length=4, blank=True) 

previous_year_wardname = models.CharField(max_length=100,blank=True, 
null=True) 

previous_doorno1 = models.CharField(max_length=4,blank=True, null=True) 

previous_doorno2 = models.CharField(max_length=10,blank=True, null=True) 

current_year = models.CharField(max_length=4, blank=True) 

current_year_wardname = models.CharField(max_length=100,blank=True, 
null=True) 

current_doorno1 = models.CharField(max_length=10,blank=True, null=True) 

current_doorno2 = models.CharField(max_length=10,blank=True, null=True) 

buildingusage = models.CharField(max_length=500,blank=True, null=True) 

ownernameaddressmal = models.CharField(max_length=500,blank=True, 
null=True) 

ownernameaddresseng = models.CharField(max_length=500,blank=True, 
null=True) 

plintaarea = models.DecimalField(max_digits=7, decimal_places=2,blank=True, 
null=True) 

class Meta: 

db_table = 'assesment_building_details' 


 
my logic is to take the numbuildingid2 as input from the text box and when 
i press enter either on the text field or click the add button it should 
search through the database
and add the details to the table without refreshing the whole page. and the 
clear the textfield and focus on it.
 It will give proper error msg if the numbuildingid2 is not found

please help how and which is the best way to implement this... 

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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cf179d74-ea55-428f-9dd0-e4ce2297d01b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


i have a question ,whether Django’s cache framework can support transparent proxy deploy mode at isp environment ?

2015-03-01 Thread 'johnzeng' via Django users


Hello All :

i have a question , if possible , hope to get your advisement

whether Django’s cache framework can support transparent proxy at isp 
environment ?


and our goal is Django’s cache framework ( middle cache layer ) + Squid 
( transparent proxy mode ) at isp environment ?



although i read the detail , but i can't confirm whether Django’s cache 
framework can support transparent proxy deploy mode


https://docs.djangoproject.com/en/1.7/topics/cache/



   Downstream caches¶
   

So far, this document has focused on caching your /own/ data. But 
another type of caching is relevant to Web development, too: caching 
performed by “downstream” caches. These are systems that cache pages for 
users even before the request reaches your Web site.


Here are a few examples of downstream caches:

 * Your ISP may cache certain pages, so if you requested a page from
   http://example.com/, your ISP would send you the page without having
   to access example.com directly. The maintainers of example.com have
   no knowledge of this caching; the ISP sits between example.com and
   your Web browser, handling all of the caching transparently.
 * Your Django Web site may sit behind a /proxy cache/, such as Squid
   Web Proxy Cache (http://www.squid-cache.org/), that caches pages for
   performance. In this case, each request first would be handled by
   the proxy, and it would be passed to your application only if needed.
 * Your Web browser caches pages, too. If a Web page sends out the
   appropriate headers, your browser will use the local cached copy for
   subsequent requests to that page, without even contacting the Web
   page again to see whether it has changed.

Downstream caching is a nice efficiency boost, but there’s a danger to 
it: Many Web pages’ contents differ based on authentication and a host 
of other variables, and cache systems that blindly save pages based 
purely on URLs could expose incorrect or sensitive data to subsequent 
visitors to those pages.


For example, say you operate a Web email system, and the contents of the 
“inbox” page obviously depend on which user is logged in. If an ISP 
blindly cached your site, then the first user who logged in through that 
ISP would have their user-specific inbox page cached for subsequent 
visitors to the site. That’s not cool.


Fortunately, HTTP provides a solution to this problem. A number of HTTP 
headers exist to instruct downstream caches to differ their cache 
contents depending on designated variables, and to tell caching 
mechanisms not to cache particular pages. We’ll look at some of these 
headers in the sections that follow.




--
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54F407CD.2030403%40yahoo.com.
For more options, visit https://groups.google.com/d/optout.


Populating Django app db with JSON data

2015-03-01 Thread Sandeep Murthy
Hi

I've tried to get the answer to this question (which is a bit open-ended) 
on stackoverflow without much success, which
is basically this: what is the recommended approach to populating a 
pre-existing Django app database table (generated
from a model and which is currently empty) with JSON data?

There seem to be several alternatives given in the Django documentation 
(Django 1.7 manual) which include (1) fixtures,
(2) SQL scripts, (3) data migrations.  Of these I am a bit confused by the 
advice in the manual which suggests that (1)
and (2) are only useful for loading initial data.  That's not what I want 
to do.  The data that the app needs is going to be
persistent and permanent because the app is intended to be a web query tool 
for a large dataset that is currently in the 
form of several JSON files, each containing on average thousands of JSON 
objects, each object representing an entry
corresponding to a table entry in a relational db.  The data is not going 
to be re-loaded or change after entry, and there
is no user facility for changing the data.

The table has been created using the makemigrations and migrate tools, but 
is empty.  I just need to populate the
table with the JSON data.  It seems that I need to write a custom data 
migration script that will insert the data into the
table via the interpreter, and then I need to run python manage.py migrate.  
Is this the case, and if so, are there
are examples that I could use?

Thanks in advance for any suggestions.

SM

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/db5919c5-ace4-4556-b90e-aa47baa26552%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Melb Django School Second GO

2015-03-01 Thread MelbDjango School
Hey Guys,

Melb Django & Common Code is starting its second round of free classes on 
Django. The classes are going to be held fortnightly starting March 12 from 
4-6pm. They will be going through the essentials of Django to advance 
topics. The course will be given by leading Django Developers in the 
industry. Please bring a laptop and we'll provide the rest. See you in 
School!

If you have any questions please contact 
melbdjangosch...@acommoncreative.com.

Cheers,
Darren

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b39acf36-3a9f-411d-8aff-a172c8bfa754%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem installing and using smart_selects

2015-03-01 Thread Carl Meyer
Hi Michael,

On 03/01/2015 01:11 AM, Michael Ackary wrote:
> Smart Selects looked so simple and promising for chained selects
> (https://github.com/digi604/django-smart-selects).  However, no matter
> how I install it, it doesn't seem to work.  Here is what I've tried:
> 
> 
> *Attempt #1 - putting it in django.contrib
> *
> Copied the smart_selects folder to /django/contrib/smart_selects
> 
> Added "django.contrib.smart_selects" to INSTALLED_APPS in settings.py
> 
> But within Django shell I got this error:
> 
  from django.contrib import smart_selects
  smart_selects.urls 
> AttributeError: 'module' object has no attribute 'urls'

You don't ever want to do this. The "django.contrib" module is for
modules distributed with Django; it's not a place to add your own
additional code.

It also doesn't work, because smart_select expects to be able to import
itself as "smart_select", not as "django.contrib.smart_select."

> *Attempt #2 - installed using pip
> *
> I removed the smart_selects folder from /django/contrib  folder (above)
> and then installed using pip... which put smart_selects in the Python
> site-packages folder.
> 
> But then trying to use smart_selects within urls.py produced an ugly
> "ImportError: cannot import name simplejson" which suggests
> smart_selects has some outdated dependencies. (I"m using Django 1.7).

This is the right way to make use of third-party code. The problem here,
as you say, is just that smart_select has some outdated code. It's
actually been fixed in master, just not posted to PyPI yet, so you'll
need to install it directly from git, as mentioned in the fourth comment
here: https://github.com/digi604/django-smart-selects/issues/70

> *Attemp #3 - putting smart_packages in the root folder of my Django project
> *
> When smart_selects is placed here, again I can import smart_selects from
> the Django shell  but not access smart-selects.urls :
> 
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
 import smart_selects
 dir(smart_selects)
> ['__builtins__', '__doc__', '__file__', '__name__', '__package__',
> '__path__', 'models']
 smart_selects.urls
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'module' object has no attribute 'urls'
> 
> 
> Finally it works if i do this:
> 
 import smart_selects.urls
 smart_selects.urls
>  '/Users/chas/Projects/switch/djangoroot/smart_selects/urls.pyc'>

The difference between the "doesn't work" and "works" versions here
doesn't have anything to do with how you've installed the code, it's
simply how submodule imports work in Python. Submodules are never
automatically imported unless you import them explicitly.

> However, I really don't like putting apps here since they clutter up my
> own development (and would rather keep 3rd party apps in django/contrib). 

Yes, this installation technique will work fine, but it clutters things
up and makes it harder to upgrade in the future.

Carl

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54F3C467.7080203%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


Re: Different between Object-save and form-save

2015-03-01 Thread Babatunde Akinyanmi
Something like that. The essence of "form_save" is to save data from a form
to the fields of the User model in the database. The thing to note is that
a Form's save method returns the object that was saved. Also, a Form's save
method and model save method do the same thing
On 1 Mar 2015 20:30, "ADEWALE ADISA"  wrote:

> OK, thanks for the response. So the essence of the form_save() is to get
> the user object in which the password property can be set properly.
> Thanks alot
> On Mar 1, 2015 6:38 PM, "Vijay Khemlani"  wrote:
>
>> Both save the user to the database, but "user_form.save()" leaves the
>> user password in plain text (which won't work when the user tries to login
>> later) so the password must be set correctly
>> (user.set_password(user.password)) and then the user has to be saved again
>> for the correct (hashed) password to be stored.
>>
>> On Sun, Mar 1, 2015 at 12:57 PM, ADEWALE ADISA 
>> wrote:
>>
>>> Hi guys, pls help with little explanation on the extract below from
>>> tango tutorial. In the code, they call user_form().save() to save into
>>> database. Then latter call user.save(). Pls what's the different between
>>> the two ? Where did user.save() save to ?
>>>
>>> from rango.forms import UserForm, UserProfileForm
>>>
>>> def register(request):
>>>
>>> # A boolean value for telling the template whether the registration
>>> was successful.
>>> # Set to False initially. Code changes value to True when
>>> registration succeeds.
>>> registered = False
>>>
>>> # If it's a HTTP POST, we're interested in processing form data.
>>> if request.method == 'POST':
>>> # Attempt to grab information from the raw form information.
>>> # Note that we make use of both UserForm and UserProfileForm.
>>> user_form = UserForm(data=request.POST)
>>> profile_form = UserProfileForm(data=request.POST)
>>>
>>> # If the two forms are valid...
>>> if user_form.is_valid() and profile_form.is_valid():
>>> # Save the user's form data to the database.
>>> user = user_form.save()
>>>
>>> # Now we hash the password with the set_password method.
>>> # Once hashed, we can update the user object.
>>> user.set_password(user.password)
>>> user.save()
>>>
>>> # Now sort out the UserProfile instance.
>>> # Since we need to set the user attribute ourselves, we set
>>> commit=False.
>>> # This delays saving the model until we're ready to avoid
>>> integrity problems.
>>> profile = profile_form.save(commit=False)
>>> profile.user = user
>>>
>>>  --
>>> 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 http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAMGzuy_saD%3DscV_CJtKzcss2siPktvFxi1oCUD-BvCEURtA5jg%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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CALn3ei34SRTYAxP4oaSExM2Nt-tjym4PXP2q2xuSgkkH8TV_UA%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMGzuy8aX8ehs4Qd2RgkueERA-OmDQg8gbE%3DVxJCB8heKw%2B03A%40mail.gmail.com
> 
> .
> For more options, 

Re: Can the new `Prefetch` solve my problem?

2015-03-01 Thread James Schneider
Ask and you shall receive (eventually). Another post in this list has an
example using Prefetch(), perhaps that will help you:

https://groups.google.com/d/msgid/django-users/3daddb38-3260-4f7d-9559-7d0d3f17b59e%40googlegroups.com?utm_medium=email_source=footer
On Feb 27, 2015 2:38 AM, "James Schneider"  wrote:

>
> On Feb 27, 2015 12:51 AM, "aRkadeFR"  wrote:
> >
> > Yeah, but from my experience, your example through a new
> > query. You have to (and please correct me if I'm wrong or
> > there are other ways) use the self.chair_set.all() in order
> > to not through a new query when you have prefetched the
> > chairs.
>
> AFAIK, self.chair_set.all() would always spawn a second query unless
> something like select_related() had been used previously to cache that
> query result
>
> I provided several examples, some of which spawn a second query (and may
> be appropriate, I can't provide an affirmative answer for the OP without
> knowing how many queries are being run per page load and average query
> time, etc.). You'll need to be more specific.
>
> I think I accidentally referred to some of the model fields as if they
> were FK's, but they probably should have had .all() after all of the
> references since everything was an M2M relationship.
>
> >
> > To be simple and answer the problem: my only solution I
> > have in mind is to prefetched all the objects (chairs), and
> > then filter it in python with properties like I said. But as you
> > said it will load too much objects...
>
> I think there was some miscommunication here. The OP stated that loading
> all of the chairs was infeasible, and I would tend to agree.
>
> My only clarification would be that loading all of the chairs via
> something like Chair.objects.all() would be a bad idea, since you have no
> idea how many chairs you may have in the entire database.
>
> Loading >10k Chair objects into memory and having Django coerce those into
> model objects, and then performing post processing in some custom app code
> to filter that list back down to something reasonable will give you a bad
> time, every time. Your users will be unhappy with pages that take seconds
> to load, and your server processes will be unhappy assuming you have plenty
> of RAM/CPU to handle such a request. Now multiply that load by X number of
> users...and you're quickly hitting CPU and process limits for RAM
> allocation.
>
> However, "loading all of the chairs" via a M2M or FK relationship such as
> desk_obj.nearby_chairs.all() (assuming the OP reconfigured the model fields
> as I suggested before, or even using the existing Chair M2M to Desk) would
> likely be perfectly valid and would probably be a small subset of the total
> chairs in the system (or maybe None or all of them).
>
> >
> > Still watching the thread cause I have couple of problems
> > like this one :)
> >
>
> I don't necessarily run in to this specific problem, so I'm not sure how
> much more I can contribute. A lot of the model changes I suggested were
> educated guesses and may not be valid at all given other requirements or
> design considerations in the project.
>
> > aRkadeFR
> >
> >
> > On 02/26/2015 08:27 PM, James Schneider wrote:
> >>
> >> Heh, I just realized that aRkadeFR had replied with a similar idea to
> use a property. At least I know I'm not too far off on my thinking. :-D
> >>
> >> -James
> >>
> >> On Thu, Feb 26, 2015 at 11:02 AM, James Schneider <
> jrschneide...@gmail.com> wrote:
> >>>
> >>> Whoops, accidentally sent that last one too early, here's the
> continuation:
> >>>
> >>> However, that probably doesn't buy you much since you are still doing
> an extra query for every Desk you pull from your original query.
> >>>
> >>> Funny enough, I was googling around for an answer here, and stumbled
> across this:
> >>>
> >>>
> https://docs.djangoproject.com/en/1.7/ref/models/queries/#django.db.models.Prefetch
> >>>
> >>> which I think is what you were referring to initially in your OP. I
> wasn't even aware of its existence. Prefetch() is a helper class for
> prefetch_related(). Taking a quick glance through the source code, I would
> imagine that it probably won't help you much, since the functionality of
> that class only controls the action of prefetch_related().
> >>>
> >>>
> >>> Zooming out a bit, the crux of your problem is this: An attribute you
> wish to populate is not an FK or M2M field, it is an entirely separate
> Queryset with some moderately complex filters. The built-in ORM
> functionality for pre-loading via prefetch/select_related() is expecting a
> FK or M2M relationship and can't  use another queryset AFAIK. The
> high-level functionality of prefetch_related() is probably close to what
> you want, which is to run a single second query to collect all of
> the favorite_or_nearby_chairs for all of the Desks in your original query,
> and then glue everything together behind the scenes in Python to make the
> 

Re: Problem installing and using smart_selects

2015-03-01 Thread Jorge Andrés Vergara Ebratt
Check the git repo, the issues page, one of the issues (I think the 4th)
says that in the tittle, Can not import simple json.

You basically have to install it with pip but from the git branch, because
they haven't updated pypy yet

On Sun, Mar 1, 2015, 6:32 PM Michael Ackary  wrote:

>
> Smart Selects looked so simple and promising for chained selects (
> https://github.com/digi604/django-smart-selects).  However, no matter how
> I install it, it doesn't seem to work.  Here is what I've tried:
>
>
>
> *Attempt #1 - putting it in django.contrib *
> Copied the smart_selects folder to /django/contrib/smart_selects
>
> Added "django.contrib.smart_selects" to INSTALLED_APPS in settings.py
>
> But within Django shell I got this error:
>
> >>>  from django.contrib import smart_selects
> >>>  smart_selects.urls
> AttributeError: 'module' object has no attribute 'urls'
>
>
>
>
> *Attempt #2 - installed using pip*
> I removed the smart_selects folder from /django/contrib  folder (above)
> and then installed using pip... which put smart_selects in the Python
> site-packages folder.
>
> But then trying to use smart_selects within urls.py produced an ugly
> "ImportError: cannot import name simplejson" which suggests smart_selects
> has some outdated dependencies. (I"m using Django 1.7).
>
>
>
>
> *Attemp #3 - putting smart_packages in the root folder of my Django
> project *
> When smart_selects is placed here, again I can import smart_selects from
> the Django shell  but not access smart-selects.urls :
>
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> import smart_selects
> >>> dir(smart_selects)
> ['__builtins__', '__doc__', '__file__', '__name__', '__package__',
> '__path__', 'models']
> >>> smart_selects.urls
> Traceback (most recent call last):
>   File "", line 1, in 
> AttributeError: 'module' object has no attribute 'urls'
>
>
> Finally it works if i do this:
>
> >>> import smart_selects.urls
> >>> smart_selects.urls
>  '/Users/chas/Projects/switch/djangoroot/smart_selects/urls.pyc'>
>
>
> However, I really don't like putting apps here since they clutter up my
> own development (and would rather keep 3rd party apps in django/contrib).
>
> What am I missing about the smart_selects ?
> Thank you,
>
> Mike,
>
> --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1034ee57-88fc-417e-a9d6-b5787815ffb9%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAeX05HdBzzjNjydDuriti9tGGfr5DNmkme-dnpDizr9bRgfqw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Query optimization - From 3 queries to 2

2015-03-01 Thread Humberto Moreira


I basically have to display a list of service providers and in each, I need 
to display the categories of service they offer.

So as an example:

Possible Service Type Categories:

[id: 1, name:'Programming'][id: 2, name:'Design']

Possible Service Types:

[id: 1, name: 'PHP Service', service_type_category_id: 1][id: 2, name: 'JAVA 
Service', service_type_category_id: 1][id: 3, name: 'Web Design Service', 
service_type_category_id: 2]

Example of Display Results:

Company Blue offers 'Programming'Company Test offers 'Programming' and 
'Design'Company Orange offers 'Design' 

I'm trying to write the least number of queries:

I have these models:

class ServiceTypeCategory( BaseModel ):

# Model Attributes
name = models.CharField( _( "name" ), max_length = 40 )

class ServiceType( BaseModel ):

# Model Attributes
service_type_category = models.ForeignKey( 'ServiceTypeCategory', 
verbose_name = _( 'category' ) )
name = models.CharField( _( "name" ), max_length = 60 )
description = models.TextField( _( "description" ) )

class Provider( BaseModel ):

# Model Attributes
display_name = models.CharField( _( "name" ), max_length = 80 )

# Many to many relations
countries = models.ManyToManyField( 'core.Country' ) # countries this 
provider support
service_types = models.ManyToManyField( 'ServiceType', through = 
'Provider_ServiceTypes', related_name = 'service_types' )

class Provider_ServiceTypes( BaseModel ):

# Model Attributes
service_type = models.ForeignKey( 'ServiceType', verbose_name = _( 'service 
type' ) )
provider = models.ForeignKey( 'Provider', verbose_name = _( 'provider' ) )
is_top = models.BooleanField( _( "is top service" ), default = False )

Then, to run the query, I have the following:

providers = Provider.objects.select_related(
'user',).prefetch_related(
Prefetch(
'service_types__service_type_category',
queryset = ServiceTypeCategory.objects
.only( 'name' )
)).filter(
countries = country_id,).only(
'id', 'display_name', 'user').order_by(
'-user__last_login')

This works out well, but it runs the 3 following queries:

SELECT app_provider.id, app_provider.user_id, app_provider.display_name, 
core_user.id, core_user.password, core_user.last_login, core_user.is_superuser, 
core_user.created_date, core_user.modified_date, core_user.email, 
core_user.name, core_user.is_active, core_user.is_admin 
FROM app_provider 
INNER JOIN app_provider_countries ON ( app_provider.id = 
app_provider_countries.provider_id ) 
INNER JOIN core_user ON ( app_provider.user_id = core_user.id ) 
LEFT OUTER JOIN core_userpersonal ON ( core_user.id = core_userpersonal.user_id 
) 
LEFT OUTER JOIN core_userstats ON ( core_user.id = core_userstats.user_id ) 
WHERE app_provider_countries.country_id = 204 
ORDER BY core_userstats.total_reviews DESC, core_userstats.total_contracts 
DESC, core_userstats.total_answers DESC, core_user.last_login DESC LIMIT 5


SELECT (app_provider_servicetypes.provider_id) AS 
_prefetch_related_val_provider_id, app_servicetype.id, 
app_servicetype.created_date, app_servicetype.modified_date, 
app_servicetype.service_type_category_id, app_servicetype.name, 
app_servicetype.description 
FROM app_servicetype 
INNER JOIN app_provider_servicetypes ON ( app_servicetype.id = 
app_provider_servicetypes.service_type_id ) 
WHERE app_provider_servicetypes.provider_id IN (2)


SELECT app_servicetypecategory.id, app_servicetypecategory.name 
FROM app_servicetypecategory 
WHERE app_servicetypecategory.id IN (1, 2)

Question is: How can I make to run just 2 queries in total? (The last 2 
queries should be joined with INNER JOIN and a group by per 
service_type_category_name)

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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3daddb38-3260-4f7d-9559-7d0d3f17b59e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Free Django Video Tutorials

2015-03-01 Thread Mike Hibbert
Hi All

Just a quick shout out to all you guys learning Django!

I have a 11+ hrs FREE tutorial series to get you started here: 
https://mikesdjangotutorials.co.uk

Check it out, there stuff there for beginners and advanced!

Mike

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8683e896-9557-4647-9ffc-68251627228a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem installing and using smart_selects

2015-03-01 Thread Michael Ackary

Smart Selects looked so simple and promising for chained selects 
(https://github.com/digi604/django-smart-selects).  However, no matter how 
I install it, it doesn't seem to work.  Here is what I've tried: 



*Attempt #1 - putting it in django.contrib *
Copied the smart_selects folder to /django/contrib/smart_selects 

Added "django.contrib.smart_selects" to INSTALLED_APPS in settings.py 

But within Django shell I got this error: 

>>>  from django.contrib import smart_selects
>>>  smart_selects.urls 
AttributeError: 'module' object has no attribute 'urls' 




*Attempt #2 - installed using pip*
I removed the smart_selects folder from /django/contrib  folder (above) and 
then installed using pip... which put smart_selects in the Python 
site-packages folder. 

But then trying to use smart_selects within urls.py produced an ugly 
"ImportError: cannot import name simplejson" which suggests smart_selects 
has some outdated dependencies. (I"m using Django 1.7). 




*Attemp #3 - putting smart_packages in the root folder of my Django project 
*
When smart_selects is placed here, again I can import smart_selects from 
the Django shell  but not access smart-selects.urls : 

Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> import smart_selects
>>> dir(smart_selects)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', 
'__path__', 'models']
>>> smart_selects.urls
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'module' object has no attribute 'urls'


Finally it works if i do this: 

>>> import smart_selects.urls
>>> smart_selects.urls



However, I really don't like putting apps here since they clutter up my own 
development (and would rather keep 3rd party apps in django/contrib).  

What am I missing about the smart_selects ? 
Thank you,

Mike, 

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1034ee57-88fc-417e-a9d6-b5787815ffb9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: "ResourceWarning: unclosed" error using mysql-connector-python

2015-03-01 Thread Aaron Abajian
I was also getting these errors, upgrading resolved them for me as well.

On Friday, July 4, 2014 at 6:59:03 AM UTC-7, Zemian Deng wrote:
>
> No problem. Thanks for the reply.
>
>
> On Fri, Jul 4, 2014 at 12:51 AM, cercatrova2  > wrote:
>
>>  On 04/07/14 05:09, Zemian Deng wrote:
>>  
>> Hum... I am surprised that no one has experienced this warning msg yet, 
>> or maybe I can't catch anyone to reply. 
>>
>>  For those are curious, I do now see mysql-connector-python 1.2.2 is 
>> available, and upgrading to this version got rid off these warnings.
>>
>> On Thursday, June 12, 2014 11:24:40 PM UTC-4, Zemian Deng wrote: 
>>>
>>> Anyone?
>>>
>>> On Tuesday, June 10, 2014 11:26:18 PM UTC-4, Zemian Deng wrote: 

 Hi there, 

  I am using mysql-connector-python (1.1.6) with Django (1.6.5) and 
 myapp is working fine. But each SQL call to DB will result the following 
 warning messages:

   Exception ignored in: >>> family=AddressFamily.AF_INET, type=SocketType.SOCK_STREAM, proto=6, 
 laddr=('127.0.0.1', 62622), raddr=('127.0.0.1', 3306)>
  
 ResourceWarning: unclosed >>> family=AddressFamily.AF_INET, type=SocketType.SOCK_STREAM, proto=6, 
 laddr=('127.0.0.1', 62622), raddr=('127.0.0.1', 3306)>
  
  
  Has anyone seen this and know a way to resolve it?
  Also, FYI, I am using the following in my settings file.
 DATABASES = {
  'default': {
'ENGINE': 'mysql.connector.django',
'NAME': 'mydb',
'USER': 'test',
'PASSWORD': 'test',
 },
 }

  Thanks,
 Zemian
  
>>>   -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/a443d950-fe72-4380-bf61-1fc9c71c9af9%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> Zemian - I saw these warning messages too with 1.1.6 but indeed they went 
>> away with 1.2.2 about a month ago so I didn't post anything. Sorry but I 
>> didn't know of your message at the time.
>>
>>
>>
>>  -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/53B632EE.2080203%40gmail.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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ea575334-f11d-4841-8ac2-1ffb4b278b14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Wysiwyg and images (Summernote or Froala)

2015-03-01 Thread Sakis Brouzioutis
Hi Dave,

I encounter the same problem. Did you find any solution?

I really don't know what is going wrong and the image does not appear.

Sakis

Τη Τετάρτη, 4 Φεβρουαρίου 2015 - 12:04:30 π.μ. UTC+2, ο χρήστης David 
Mutton έγραψε:
>
> Hi,
> I've been trying to integrate a WYSIWYG editor into my Django project. I 
> first started with Summernote and I had no issue integrating the it into 
> admin or a form. I followed the instructions on their github and everything 
> works great except image uploading and inserting. The file is uploading (I 
> can see it in the filesystem) but it does not show up in the editor or in 
> the resulting html.
>
> I thought it was just Summernote and so I switched to Froala but I'm 
> getting the exact same behavior. Is there something I'm missing with image 
> upload inside a wysiwyg?
>
>
> Dave 
>
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a0eb7cff-6423-4f86-b4ac-fea9604e6604%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[1.8] MultiHost with template dir per Host

2015-03-01 Thread Neyoui
Hi,

I had create a middleware, that is able to change the template directory 
per host on the fly.
But it stopped working since I upgraed to Django 1.8 and I tried to fix it.

My problem is:
If I visit domain1.tld, all works fine. Django loads the templates from the 
right directory. (/path/domain1.tld/templates/)
But if I visit now domain2.tld, Django tried to load the template from the 
domain1.tld directory /path/domain1.tld/templates/ and not from 
/path/domain2.tld/templates/.
The debug messages shows me, that the middleware overrides the template 
path successfully.

Maybe someone can help me to fix it.

Details:
Django version: 1.8b1
Python: 3.4

If you need some other information, just ask for it.

- settings.py

MIDDLEWARE_CLASSES = (
'core.middleware.MultiHostMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
...
)


TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
],
'loaders': [
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
],
'debug': True
},
},
]


ROOT_URLCONF = 'core.urls'

HOST_MIDDLEWARE_TEMPLATE_DIRS = {
   "domain1.tld": BASE_DIR + "/domain1.tld/templates/",
   "domain2.tld": BASE_DIR + "/domain2.tld/templates/",
}

HOST_MIDDLEWARE_URLCONF_MAP = {
   "domain1.tld": "domain1.urls",
   "domain2.tld": "domain2.urls",
}


INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'core',
'domain1',
'domain2',
)


- middleware.py

from django.conf import settings
from django.utils.cache import patch_vary_headers


class MultiHostMiddleware:

def get_settings(self, request):

host = request.META["HTTP_HOST"]
host_port = host.split(':')

if len(host_port) == 2:
host = host_port[0]

if host in settings.HOST_MIDDLEWARE_URLCONF_MAP:

urlconf = settings.HOST_MIDDLEWARE_URLCONF_MAP[host]
template_dirs = settings.HOST_MIDDLEWARE_TEMPLATE_DIRS[host],

else:
urlconf = settings.ROOT_URLCONF
template_dirs = None

return urlconf, tuple(template_dirs)

def process_request(self, request):

urlconf, template_dirs = self.get_settings(request)

request.urlconf = urlconf
settings.TEMPLATES[0]['DIRS'] = template_dirs

def process_response(self, request, response):

if getattr(request, "urlconf", None):
patch_vary_headers(response, ('Host',))

return response




-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/68d650a9-db37-46b9-8407-9eafd1404158%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Form In modal

2015-03-01 Thread Emerson Luiz
Hi,

I have the following problem:

I need to set up a form, that when the OK button is clicked, it passes a 
parameter and open a modal with the result.
Today the query works as follows:

http://127.0.0.1:8000/consulta/?consulta=31

The 31 is the parameter.

return:

Operadora  TipoCLAROMOVEL



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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9f8e5cbb-45a0-464d-9047-6ccfdc0a4757%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Using proxy kind of Table in Admin Interface

2015-03-01 Thread Rootz
Question.
How would one go about designing the django table(s) so that I can assign 
each user account/group a different Model Manager using the same table in 
the Django admin interface? 

After doing some reading the closest that comes to this is the Proxy Model 
but I tried adding the proxy model manually into the django admin and got 
an error while loading it. 

My goal is to create one table that returns a custom QuerySet unique to a 
user group or user account. Adding to this I would like for this to be 
visible in the admin interface. Can you guide me as to how can achieve this.

thank you 

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cd13f5ab-633e-4361-a621-cfc11d5d01a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Different between Object-save and form-save

2015-03-01 Thread ADEWALE ADISA
OK, thanks for the response. So the essence of the form_save() is to get
the user object in which the password property can be set properly.
Thanks alot
On Mar 1, 2015 6:38 PM, "Vijay Khemlani"  wrote:

> Both save the user to the database, but "user_form.save()" leaves the user
> password in plain text (which won't work when the user tries to login
> later) so the password must be set correctly
> (user.set_password(user.password)) and then the user has to be saved again
> for the correct (hashed) password to be stored.
>
> On Sun, Mar 1, 2015 at 12:57 PM, ADEWALE ADISA 
> wrote:
>
>> Hi guys, pls help with little explanation on the extract below from tango
>> tutorial. In the code, they call user_form().save() to save into database.
>> Then latter call user.save(). Pls what's the different between the two ?
>> Where did user.save() save to ?
>>
>> from rango.forms import UserForm, UserProfileForm
>>
>> def register(request):
>>
>> # A boolean value for telling the template whether the registration
>> was successful.
>> # Set to False initially. Code changes value to True when
>> registration succeeds.
>> registered = False
>>
>> # If it's a HTTP POST, we're interested in processing form data.
>> if request.method == 'POST':
>> # Attempt to grab information from the raw form information.
>> # Note that we make use of both UserForm and UserProfileForm.
>> user_form = UserForm(data=request.POST)
>> profile_form = UserProfileForm(data=request.POST)
>>
>> # If the two forms are valid...
>> if user_form.is_valid() and profile_form.is_valid():
>> # Save the user's form data to the database.
>> user = user_form.save()
>>
>> # Now we hash the password with the set_password method.
>> # Once hashed, we can update the user object.
>> user.set_password(user.password)
>> user.save()
>>
>> # Now sort out the UserProfile instance.
>> # Since we need to set the user attribute ourselves, we set
>> commit=False.
>> # This delays saving the model until we're ready to avoid
>> integrity problems.
>> profile = profile_form.save(commit=False)
>> profile.user = user
>>
>>  --
>> 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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMGzuy_saD%3DscV_CJtKzcss2siPktvFxi1oCUD-BvCEURtA5jg%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei34SRTYAxP4oaSExM2Nt-tjym4PXP2q2xuSgkkH8TV_UA%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMGzuy8aX8ehs4Qd2RgkueERA-OmDQg8gbE%3DVxJCB8heKw%2B03A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Different between Object-save and form-save

2015-03-01 Thread Vijay Khemlani
Both save the user to the database, but "user_form.save()" leaves the user
password in plain text (which won't work when the user tries to login
later) so the password must be set correctly
(user.set_password(user.password)) and then the user has to be saved again
for the correct (hashed) password to be stored.

On Sun, Mar 1, 2015 at 12:57 PM, ADEWALE ADISA 
wrote:

> Hi guys, pls help with little explanation on the extract below from tango
> tutorial. In the code, they call user_form().save() to save into database.
> Then latter call user.save(). Pls what's the different between the two ?
> Where did user.save() save to ?
>
> from rango.forms import UserForm, UserProfileForm
>
> def register(request):
>
> # A boolean value for telling the template whether the registration
> was successful.
> # Set to False initially. Code changes value to True when registration
> succeeds.
> registered = False
>
> # If it's a HTTP POST, we're interested in processing form data.
> if request.method == 'POST':
> # Attempt to grab information from the raw form information.
> # Note that we make use of both UserForm and UserProfileForm.
> user_form = UserForm(data=request.POST)
> profile_form = UserProfileForm(data=request.POST)
>
> # If the two forms are valid...
> if user_form.is_valid() and profile_form.is_valid():
> # Save the user's form data to the database.
> user = user_form.save()
>
> # Now we hash the password with the set_password method.
> # Once hashed, we can update the user object.
> user.set_password(user.password)
> user.save()
>
> # Now sort out the UserProfile instance.
> # Since we need to set the user attribute ourselves, we set
> commit=False.
> # This delays saving the model until we're ready to avoid
> integrity problems.
> profile = profile_form.save(commit=False)
> profile.user = user
>
>  --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMGzuy_saD%3DscV_CJtKzcss2siPktvFxi1oCUD-BvCEURtA5jg%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei34SRTYAxP4oaSExM2Nt-tjym4PXP2q2xuSgkkH8TV_UA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python / Django slow ? Deciding my next technological stack

2015-03-01 Thread Avraham Serour
if you have so many uploads that all of yours workers are busy, so maybe
you need more workers...

On Sun, Mar 1, 2015 at 5:38 PM, Vijay Khemlani  wrote:

> The rest of the uWSGI / gunicorn / whatever workers are available to
> handle the other requests.
>
> If there are so many uploads that all of the workers are busy then there
> are ways to upload files directly to Amazon S3 (for example) from the
> browser without going through your server.
>
> On Sun, Mar 1, 2015 at 12:16 PM, Benj  wrote:
>
>> Just a little questions guys: when a user upload a file to server, and
>> that file is a litte big and takes 3 seconds to be uploaded... what's the
>> proper way, if possible, not to block the entire system for these 3 seconds
>> so the server can serve other users while the upload is taking place.
>> Should this be done in code with things like asyncio, or server with uwsgi
>> workers ?
>>
>> On Wednesday, February 25, 2015 at 3:28:34 PM UTC+1, Tom Evans wrote:
>>
>>> On Tue, Feb 24, 2015 at 11:30 PM, Benj  wrote:
>>> > Hi,
>>> > i'm going to invest lots of time and energy in various web projects
>>> (mostly
>>> > community web sites), and want to pick up a language / framework and
>>> invest
>>> > heavily on it.
>>> > I've spent a lot of time evaluating the various options, and narrowed
>>> my
>>> > choice to 2 stacks: C sharp asp.net  MVC or Python / Django.
>>> >
>>> > I'm more attracted to Python / Django combo, because of the Python
>>> language,
>>> > and high level framework Django. I really want to use these.
>>> > My only concern is speed. I read that Python can't run concurrent
>>> tasks, is
>>> > this true ? So a multi-processor with hyperthreads won't benefit the
>>> stack
>>> > and even slow it down ?
>>> > I have no clue how this translates in reality, but should I expect
>>> noticable
>>> > performance difference on a same server, shall I use Python / Django
>>> than if
>>> > I had C Sharp Asp.net ?
>>> > I don't want to invest lots of time and efforts only to discover in
>>> the end
>>> > that the site is slow.
>>> > You that have real world experiences with running sites, what are your
>>> > conclusions ?
>>> >
>>> >
>>> > I expect sites to be medium traffic: could be handled by a good
>>> dedicated
>>> > server or average cloud ressources.
>>> >
>>> > Benj
>>>
>>> Unless you are producing web-scale sites (gmail, ebay, instagram), the
>>> speed of your website will depend more upon what you do with a
>>> framework than the framework you choose.
>>>
>>> If you are producing web-scale sites, then whatever framework you
>>> choose you will need to make the right design decisions and/or
>>> compromises.
>>>
>>> Even with the best framework in the world, if you design the
>>> architecture of a website poorly, the website will be slow.
>>>
>>> Even less important than the choice of framework is the choice of
>>> hosting container for your framework. If you ever get to the point
>>> where the speed of your wsgi container is the thing that is holding
>>> you back, well done, now you should spend some time looking at it.
>>> Until then, use the way that is easiest for you.
>>>
>>> Cheers
>>>
>>> Tom
>>>
>>  --
>> 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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/cfe76a80-af35-4894-a18d-2717c371235c%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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei2bnQi0FxpMTtvZ1OAP%3D_Q2k0XJze06mv7vCKLc%3D%2BTikQ%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 

Different between Object-save and form-save

2015-03-01 Thread ADEWALE ADISA
Hi guys, pls help with little explanation on the extract below from tango
tutorial. In the code, they call user_form().save() to save into database.
Then latter call user.save(). Pls what's the different between the two ?
Where did user.save() save to ?

from rango.forms import UserForm, UserProfileForm

def register(request):

# A boolean value for telling the template whether the registration was
successful.
# Set to False initially. Code changes value to True when registration
succeeds.
registered = False

# If it's a HTTP POST, we're interested in processing form data.
if request.method == 'POST':
# Attempt to grab information from the raw form information.
# Note that we make use of both UserForm and UserProfileForm.
user_form = UserForm(data=request.POST)
profile_form = UserProfileForm(data=request.POST)

# If the two forms are valid...
if user_form.is_valid() and profile_form.is_valid():
# Save the user's form data to the database.
user = user_form.save()

# Now we hash the password with the set_password method.
# Once hashed, we can update the user object.
user.set_password(user.password)
user.save()

# Now sort out the UserProfile instance.
# Since we need to set the user attribute ourselves, we set
commit=False.
# This delays saving the model until we're ready to avoid
integrity problems.
profile = profile_form.save(commit=False)
profile.user = user

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMGzuy_saD%3DscV_CJtKzcss2siPktvFxi1oCUD-BvCEURtA5jg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python / Django slow ? Deciding my next technological stack

2015-03-01 Thread Vijay Khemlani
The rest of the uWSGI / gunicorn / whatever workers are available to handle
the other requests.

If there are so many uploads that all of the workers are busy then there
are ways to upload files directly to Amazon S3 (for example) from the
browser without going through your server.

On Sun, Mar 1, 2015 at 12:16 PM, Benj  wrote:

> Just a little questions guys: when a user upload a file to server, and
> that file is a litte big and takes 3 seconds to be uploaded... what's the
> proper way, if possible, not to block the entire system for these 3 seconds
> so the server can serve other users while the upload is taking place.
> Should this be done in code with things like asyncio, or server with uwsgi
> workers ?
>
> On Wednesday, February 25, 2015 at 3:28:34 PM UTC+1, Tom Evans wrote:
>
>> On Tue, Feb 24, 2015 at 11:30 PM, Benj  wrote:
>> > Hi,
>> > i'm going to invest lots of time and energy in various web projects
>> (mostly
>> > community web sites), and want to pick up a language / framework and
>> invest
>> > heavily on it.
>> > I've spent a lot of time evaluating the various options, and narrowed
>> my
>> > choice to 2 stacks: C sharp asp.net  MVC or Python / Django.
>> >
>> > I'm more attracted to Python / Django combo, because of the Python
>> language,
>> > and high level framework Django. I really want to use these.
>> > My only concern is speed. I read that Python can't run concurrent
>> tasks, is
>> > this true ? So a multi-processor with hyperthreads won't benefit the
>> stack
>> > and even slow it down ?
>> > I have no clue how this translates in reality, but should I expect
>> noticable
>> > performance difference on a same server, shall I use Python / Django
>> than if
>> > I had C Sharp Asp.net ?
>> > I don't want to invest lots of time and efforts only to discover in the
>> end
>> > that the site is slow.
>> > You that have real world experiences with running sites, what are your
>> > conclusions ?
>> >
>> >
>> > I expect sites to be medium traffic: could be handled by a good
>> dedicated
>> > server or average cloud ressources.
>> >
>> > Benj
>>
>> Unless you are producing web-scale sites (gmail, ebay, instagram), the
>> speed of your website will depend more upon what you do with a
>> framework than the framework you choose.
>>
>> If you are producing web-scale sites, then whatever framework you
>> choose you will need to make the right design decisions and/or
>> compromises.
>>
>> Even with the best framework in the world, if you design the
>> architecture of a website poorly, the website will be slow.
>>
>> Even less important than the choice of framework is the choice of
>> hosting container for your framework. If you ever get to the point
>> where the speed of your wsgi container is the thing that is holding
>> you back, well done, now you should spend some time looking at it.
>> Until then, use the way that is easiest for you.
>>
>> Cheers
>>
>> Tom
>>
>  --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cfe76a80-af35-4894-a18d-2717c371235c%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei2bnQi0FxpMTtvZ1OAP%3D_Q2k0XJze06mv7vCKLc%3D%2BTikQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python / Django slow ? Deciding my next technological stack

2015-03-01 Thread Benj
Just a little questions guys: when a user upload a file to server, and that 
file is a litte big and takes 3 seconds to be uploaded... what's the proper 
way, if possible, not to block the entire system for these 3 seconds so the 
server can serve other users while the upload is taking place. Should this 
be done in code with things like asyncio, or server with uwsgi workers ?

On Wednesday, February 25, 2015 at 3:28:34 PM UTC+1, Tom Evans wrote:
>
> On Tue, Feb 24, 2015 at 11:30 PM, Benj  
> wrote: 
> > Hi, 
> > i'm going to invest lots of time and energy in various web projects 
> (mostly 
> > community web sites), and want to pick up a language / framework and 
> invest 
> > heavily on it. 
> > I've spent a lot of time evaluating the various options, and narrowed my 
> > choice to 2 stacks: C sharp asp.net  MVC or Python / Django. 
> > 
> > I'm more attracted to Python / Django combo, because of the Python 
> language, 
> > and high level framework Django. I really want to use these. 
> > My only concern is speed. I read that Python can't run concurrent tasks, 
> is 
> > this true ? So a multi-processor with hyperthreads won't benefit the 
> stack 
> > and even slow it down ? 
> > I have no clue how this translates in reality, but should I expect 
> noticable 
> > performance difference on a same server, shall I use Python / Django 
> than if 
> > I had C Sharp Asp.net ? 
> > I don't want to invest lots of time and efforts only to discover in the 
> end 
> > that the site is slow. 
> > You that have real world experiences with running sites, what are your 
> > conclusions ? 
> > 
> > 
> > I expect sites to be medium traffic: could be handled by a good 
> dedicated 
> > server or average cloud ressources. 
> > 
> > Benj 
>
> Unless you are producing web-scale sites (gmail, ebay, instagram), the 
> speed of your website will depend more upon what you do with a 
> framework than the framework you choose. 
>
> If you are producing web-scale sites, then whatever framework you 
> choose you will need to make the right design decisions and/or 
> compromises. 
>
> Even with the best framework in the world, if you design the 
> architecture of a website poorly, the website will be slow. 
>
> Even less important than the choice of framework is the choice of 
> hosting container for your framework. If you ever get to the point 
> where the speed of your wsgi container is the thing that is holding 
> you back, well done, now you should spend some time looking at it. 
> Until then, use the way that is easiest for you. 
>
> Cheers 
>
> Tom 
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cfe76a80-af35-4894-a18d-2717c371235c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python / Django slow ? Deciding my next technological stack

2015-03-01 Thread Benj
Just a little questions guys: when a user upload a file to server, and that 
file is a litte big and takes 3 seconds to be uploaded... what's the proper 
way, if possible, not to block the entire system for these 3 seconds so the 
server can serve other users while the upload is taking place.

On Wednesday, February 25, 2015 at 3:28:34 PM UTC+1, Tom Evans wrote:
>
> On Tue, Feb 24, 2015 at 11:30 PM, Benj  
> wrote: 
> > Hi, 
> > i'm going to invest lots of time and energy in various web projects 
> (mostly 
> > community web sites), and want to pick up a language / framework and 
> invest 
> > heavily on it. 
> > I've spent a lot of time evaluating the various options, and narrowed my 
> > choice to 2 stacks: C sharp asp.net  MVC or Python / Django. 
> > 
> > I'm more attracted to Python / Django combo, because of the Python 
> language, 
> > and high level framework Django. I really want to use these. 
> > My only concern is speed. I read that Python can't run concurrent tasks, 
> is 
> > this true ? So a multi-processor with hyperthreads won't benefit the 
> stack 
> > and even slow it down ? 
> > I have no clue how this translates in reality, but should I expect 
> noticable 
> > performance difference on a same server, shall I use Python / Django 
> than if 
> > I had C Sharp Asp.net ? 
> > I don't want to invest lots of time and efforts only to discover in the 
> end 
> > that the site is slow. 
> > You that have real world experiences with running sites, what are your 
> > conclusions ? 
> > 
> > 
> > I expect sites to be medium traffic: could be handled by a good 
> dedicated 
> > server or average cloud ressources. 
> > 
> > Benj 
>
> Unless you are producing web-scale sites (gmail, ebay, instagram), the 
> speed of your website will depend more upon what you do with a 
> framework than the framework you choose. 
>
> If you are producing web-scale sites, then whatever framework you 
> choose you will need to make the right design decisions and/or 
> compromises. 
>
> Even with the best framework in the world, if you design the 
> architecture of a website poorly, the website will be slow. 
>
> Even less important than the choice of framework is the choice of 
> hosting container for your framework. If you ever get to the point 
> where the speed of your wsgi container is the thing that is holding 
> you back, well done, now you should spend some time looking at it. 
> Until then, use the way that is easiest for you. 
>
> Cheers 
>
> Tom 
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7e783c1f-2c44-4110-8dd9-933b489ac9ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.