Migrations and FileField storage

2014-11-12 Thread Nico Benitez
I have a question about storage objects in a migration enabled project.

I have a project that uses a file system storage backend for storing
certain model FileFields, but the location is dependent on the deployment
and stored in the settings module. For example, for testing locally I have
the storage root pointed at a directory under my home folder. Whenever I
run makemigration, it tries to alter all the FileFields to reflect whatever
the current setting is, even though this does not affect the database.

Is there a way to prevent the storage parameter from getting serialized in
the migration? If not, what is a good way to handle storing files in
different locations depending on a configuration, without a bunch of
unnecessary migrations?

-- 
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/CAK2-mOmtd9gPPGHy4SogMh-Md%3DkcrZ6HU7YWSaNYxEDVkeyQSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Modifying a ModelAdmin instance at runtime

2014-11-12 Thread Peter Sagerson
> Your analysis is entirely correct, as far as I can tell. Setting
> attributes on `self` in a per-request method of a `ModelAdmin` is not
> concurrency-safe, and it should not be recommended or demonstrated in
> the docs. If you'd be willing to file a bug (or, better, a PR) to fix
> this documentation example, that would be excellent.

Will do, thanks for the sanity check.

-- 
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/AC15DBCF-3DE0-4B23-89BD-040188CA81C5%40ignorare.net.
For more options, visit https://groups.google.com/d/optout.


Re: Modifying a ModelAdmin instance at runtime

2014-11-12 Thread Carl Meyer
Hi Peter,

On 11/12/2014 10:59 PM, Peter Sagerson wrote:
> I agree that setting self.exclude will set the instance attribute,
> thus hiding the class attribute of the same name. However, it appears
> that a given AdminSite instantiates each registered ModelAdmin once
> at registration time.[1] The default AdminSite itself is a module
> global. Thus, any long-running, multi-threaded Django application
> server (e.g. a threaded uWSGI process) might be relying on a given
> ModelAdmin instance to serve multiple requests concurrently. Neither
> AdminSite nor ModelAdmin appear to have any thread-locality,
> suggesting that modifying self.exclude (or anything else) for an
> individual request is a race condition waiting to happen.
> 
> I believe this is essentially a subtle documentation bug, although
> it's worth asking whether there are any deeper assumptions about
> ModelAdmin or AdminSite having any kind of request isolation.

Your analysis is entirely correct, as far as I can tell. Setting
attributes on `self` in a per-request method of a `ModelAdmin` is not
concurrency-safe, and it should not be recommended or demonstrated in
the docs. If you'd be willing to file a bug (or, better, a PR) to fix
this documentation example, that would be excellent.

I don't know of any bugs of this type in Django itself, but it's
certainly possible there are some. It shouldn't be too hard to audit for
them - if you find one, definitely file it as an issue.

Unfortunately I would expect bugs like this to become only more common
in user code going forward, since the class-based-views framework does
behind-the-scenes magic to make `self` concurrency-safe in CBVs, so it's
likely that users will transfer those expectations to their `ModelAdmin`
classes.

Thanks!

Carl



signature.asc
Description: OpenPGP digital signature


Re: moving existing django projects

2014-11-12 Thread Carl Meyer
Hi Malik,

On 11/12/2014 08:27 PM, Malik Rumi wrote:
> Q: This is a ‘help me understand how this works / what it does’ question
> rather than a ‘help me I’m stuck’ question. I have an existing Django
> project I wanted to get on Heroku. I created a new site on Heroku,
> uploaded my project, and ran migrations. But all I have is a generic
> new, empty Django site. The Django admin knows nothing about my models.
> Now, granted, I have not yet put up my existing database but I expected
> it to at least create the tables for my models, which it did not. Of
> course they are in installed apps, but I did not run ‘startapp’ since
> the app already exists. So why didn’t this work? 

I don't know why it isn't working. What WSGI server are you using in the
Heroku deployment? Can you point to the instructions you followed to
deploy your project on Heroku?

> Or, should the question be: 'in the case of moving a pre-existing
> project, what do you do /instead /of 'startapp''?

Nothing. Just migrate.

> Or maybe I have to run startapp anyway? Why?

Startapp is nothing but a convenience to pre-generate a skeleton of some
files; it is precisely and entirely equivalent to creating those same
files yourself in your codebase.

Personally, I never use "startapp" at all, even to create an app in the
first place.

It is certainly not necessary to run it for existing apps on new
deployments.

Carl



signature.asc
Description: OpenPGP digital signature


Re: Django + Database Connections

2014-11-12 Thread Edward Armes
  Hi Russell,

Thank you for your response it has mainly answered my questions as well as 
given me areas to think about where to insert the asynchronous layer.

Edward

On Tuesday, 11 November 2014 21:25:44 UTC, Russell Keith-Magee wrote:
>
> Hi Edward,
>
> On Tue, Nov 11, 2014 at 12:30 AM, Edward Armes  > wrote:
>
>> Hi there,
>>
>> I am currently looking at Django for a personal project. While I 
>> understand how a lot of it works I can't wrap my head around how the actual 
>> DB querying is done specifically what part of Django actually looks at the 
>> database (I'm not talking about Manager, Models or Querysets, but the 
>> actual parts of Django that use the ORM's to get data from the database 
>> itself).
>>
>> If a reason is required without going into detail on my current 
>> half-baked idea, I'm specifically looking how to handle database operations 
>> that have a significant return time by marrying asynchronous environments 
>> with synchronous ones. While it may be more efficant to use a non-Django 
>> database handler. For now I want to look into using the Django framework 
>> without needing additional imports.
>>
>>
> It's not that a *reason* is required - it's that it's not entirely clear 
> what you're asking for.
>
> The thing is, Django *itself* doesn't do a lot of querying - Django is a 
> template system, and a forms layer, and a database ORM, all nicely 
> integrated, so you can easily compose the pieces to do something useful. 
> There are places where the forms layer will issue queries (e.g., if you 
> want to display a form that has a  representing the available 
> options from a model), but that's really at the level of "give me a 
> queryset that represents the options I want to display".
>
> The only part of Django *itself* that "uses" Django is the contents of the 
> contrib apps - most importantly, contrib.admin, but there are others.
>
> The idea of marrying async and synchronous environments isn't a new one - 
> it was the subject of a Google Summer of Code project this year, the result 
> of which will hopefully be committed to trunk for 1.8. The core of that 
> project was to formalise the API around Django's model layer so that you 
> can write a "duck typed" object that will be a substitute for a Django 
> model (subject to certain constraints and limitations). Search the 
> Django-Developer archive for "Meta Refactor" if you want more details. 
> However, that won't let you get away "without needing additional imports" - 
> at some point, you're going to need to import your async layer, because 
> Django doesn't have one.
>
> I don't know if any of this helps... hopefully it does :-)
>
> Yours,
> Russ Magee %-)
>
>

-- 
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/8d2f2ea6-10cc-4d43-adbb-0ce17515c36d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Retrieving other fields along with ValueQueryset

2014-11-12 Thread Collin Anderson
Hello,

I feel like this sort of query comes up a lot and there isn't a good 
solution.

One option would be to somehow do a _second_ query that gets all of the 
Batting objects for each of the year, score pairs.

Or, you could a query for each year and sort by score.

Or, it might be possible to get the info using extra().

You could also do the sorting and grouping by hand using python if there's 
not too much data.

Collin

On Sunday, November 2, 2014 3:08:19 PM UTC-5, Joel Goldstick wrote:
>
> Using v1.6 
>
> On Sun, Nov 2, 2014 at 2:18 PM, Joel Goldstick  > wrote: 
> > I have a model with a year field and a score field, as well as other 
> > fields. I want to get the highest score for each year. I can do that 
> > with this: 
> > 
> > Batting.objects.values('year').annotate(category=Max('score')) 
> > 
> > But I also want to display the the name associated with the highest 
> > score. The name is in a table that is linked by a foreign key. My 
> > results contain only the year and the Max value. 
> > 
> > How can I get the name in my queryset but still group by year only? 
> > 
> > 
> > -- 
> > Joel Goldstick 
> > http://joelgoldstick.com 
>
>
>
> -- 
> Joel Goldstick 
> http://joelgoldstick.com 
>

-- 
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/0ad9ae1f-c21a-47cc-bd94-ce42dafeedda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Modifying a ModelAdmin instance at runtime

2014-11-12 Thread Peter Sagerson
I agree that setting self.exclude will set the instance attribute, thus hiding 
the class attribute of the same name. However, it appears that a given 
AdminSite instantiates each registered ModelAdmin once at registration time.[1] 
The default AdminSite itself is a module global. Thus, any long-running, 
multi-threaded Django application server (e.g. a threaded uWSGI process) might 
be relying on a given ModelAdmin instance to serve multiple requests 
concurrently. Neither AdminSite nor ModelAdmin appear to have any 
thread-locality, suggesting that modifying self.exclude (or anything else) for 
an individual request is a race condition waiting to happen.

I believe this is essentially a subtle documentation bug, although it's worth 
asking whether there are any deeper assumptions about ModelAdmin or AdminSite 
having any kind of request isolation. 

Thanks,
Peter


[1] 
https://github.com/django/django/blob/master/django/contrib/admin/sites.py#L104


> On Nov 12, 2014, at 1:36 PM, Collin Anderson  wrote:
> 
> On Tuesday, November 11, 2014 3:24:48 PM UTC-5, Peter Sagerson wrote:
> The documentation of ModelAdmin.get_form()[1] demonstrates modifying 
> self.exclude in order to modify the add/change form on a per-request basis. 
> However, looking at django.contrib.admin, it seems clear that ModelAdmin is 
> instantiated when it's installed, not for every request. It also doesn't 
> appear to be a subclass of threading.local. Is there some reason this isn't a 
> terrible idea or is the example just in error?
> 
> Thanks,
> Peter
> 
> 
> [1] 
> https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_form
> 
> Hi Peter,
> 
> I've never thought that way about admin classes before, but it should work 
> correctly.
> 
> In Python, setting self.exclude = ['something'] will set a _new_ attribute on 
> on the object, the instance of the admin class, not the admin class itself, 
> even if there's a matching attribute on the class with that name. You'll end 
> up with two different exclude lists. One in self.__class__.__dict__ (aka 
> vars(type(self))) (which is now pretty hidden) and one in self.__dict__ (aka 
> vars(self)).
> 
> Though, if you _mutate_ the original attribute, like 
> self.exclude.append('something'), it will mutate the exclude list on the 
> class.
> 
> Collin
> 
> 
> -- 
> 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/AmoUDtEefyA/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/be985862-c203-4358-bc78-8988a295f733%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/2D8BB5C1-879F-4D10-9A79-98ECD26C682A%40ignorare.net.
For more options, visit https://groups.google.com/d/optout.


Re: Chrome Desktop Notification for Django

2014-11-12 Thread Collin Anderson
Hello,

>From a front-end standpoint, I personally like EventSource for this, though 
you could also use websockets or polling (checking every few 
minutes/seconds).

https://developer.mozilla.org/en-US/docs/Web/API/EventSource
http://en.wikipedia.org/wiki/Server-sent_events

Collin

On Tuesday, November 11, 2014 8:12:43 PM UTC-5, Max Nathaniel Ho wrote:
>
> I found this excellent example on Chrome Desktop Notification - Chrome 
> desktop notification example? 
> 
>
> I am able to create the Desktop Notification by clicking a button. 
>
> However, that is pretty front-end. 
>
> I would like to find out how to link an event in the web app. For example, 
>  the event could be someone posting a job for a freelance work. And user 
> who is logged into the web app but not actively browsing on the web page 
> will be notified via the Chrome Desktop Notification. 
>
> Are there any examples of how I can create a Event Handler to listen to 
> data in the backend, and prompt the user via the Desktop Notification?
>
> Many 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/c162fe08-81fa-4a25-aa55-30bd2821ce2b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Modifying a ModelAdmin instance at runtime

2014-11-12 Thread Collin Anderson
On Tuesday, November 11, 2014 3:24:48 PM UTC-5, Peter Sagerson wrote:
>
> The documentation of ModelAdmin.get_form()[1] demonstrates modifying 
> self.exclude in order to modify the add/change form on a per-request basis. 
> However, looking at django.contrib.admin, it seems clear that ModelAdmin is 
> instantiated when it's installed, not for every request. It also doesn't 
> appear to be a subclass of threading.local. Is there some reason this isn't 
> a terrible idea or is the example just in error?
>
> Thanks,
> Peter
>
>
> [1] 
> https://docs.djangoproject.com/en/1.7/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_form
>

Hi Peter,

I've never thought that way about admin classes before, but it should work 
correctly.

In Python, setting self.exclude = ['something'] will set a _new_ attribute 
on on the object, the instance of the admin class, not the admin class 
itself, even if there's a matching attribute on the class with that name. 
You'll end up with two different exclude lists. One in 
self.__class__.__dict__ (aka vars(type(self))) (which is now pretty hidden) 
and one in self.__dict__ (aka vars(self)).

Though, if you _mutate_ the original attribute, like 
self.exclude.append('something'), it will mutate the exclude list on the 
class.

Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@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/be985862-c203-4358-bc78-8988a295f733%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Where does django store auth migrations?

2014-11-12 Thread Collin Anderson
Hello,

Just checking, do you have AUTH_USER_MODULE = 'emailcustomuser.User'?

Did you mark emailcustomuser.User as "swappable" by chance? (I don't think 
you want to do that)

Thanks,
Collin

On Monday, November 10, 2014 5:43:23 AM UTC-5, Dr Ed wrote:
>
> Hi Markus,
>
> I don't really think it's the Custom model that's at fault here - this 
> migration was created months ago. The point is that auth migrations are 
> stored in, to my mind, the wrong place (in /Users//.virtualenvs/
> /lib/python2.7/site-packages/django/contrib/auth/) and a separate problem 
> revealed this to me. I've included a stack trace below though.
>
> Cheers,
>
> Ed
>
> Running migrations:
>   Applying 
> auth.0002_customer_payingcustomer_projectmanager_staff...Traceback (most 
> recent call last):
>   File "./manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File 
> "/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 385, in execute_from_command_line
> utility.execute()
>   File 
> "/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 377, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/core/management/base.py",
>  
> line 288, in run_from_argv
> self.execute(*args, **options.__dict__)
>   File 
> "/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/core/management/base.py",
>  
> line 338, in execute
> output = self.handle(*args, **options)
>   File 
> "/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
>  
> line 160, in handle
> executor.migrate(targets, plan, fake=options.get("fake", False))
>   File 
> "/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/db/migrations/executor.py",
>  
> line 63, in migrate
> self.apply_migration(migration, fake=fake)
>   File 
> "/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/db/migrations/executor.py",
>  
> line 91, in apply_migration
> if self.detect_soft_applied(migration):
>   File 
> "/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/db/migrations/executor.py",
>  
> line 135, in detect_soft_applied
> apps = project_state.render()
>   File 
> "/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/db/migrations/state.py",
>  
> line 67, in render
> model.render(self.apps)
>   File 
> "/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/db/migrations/state.py",
>  
> line 311, in render
> body,
>   File 
> "/Users//.virtualenvs/gu_portal/lib/python2.7/site-packages/django/db/models/base.py",
>  
> line 155, in __new__
> raise TypeError("%s cannot proxy the swapped model '%s'." % (name, 
> base_meta.swapped))
> TypeError: PayingCustomer cannot proxy the swapped model 
> 'emailcustomuser.User'.
>
>
>
> On Monday, 10 November 2014 09:35:29 UTC+1, Markus Holtermann wrote:
>>
>> Hey Ed,
>>
>> you certainly don't have to copy the virtualenv over to production!
>>
>> Can you share some insights on your custom user model and your settings. 
>> A complete traceback, if you have any, helps too.
>>
>> /Markus
>>
>> On Monday, November 10, 2014 9:00:04 AM UTC+1, Dr Ed wrote:
>>>
>>>
>>>
>>> On Sunday, 9 November 2014 14:50:54 UTC+1, Daniel Roseman wrote:

 On Sunday, 9 November 2014 13:40:12 UTC, Dr Ed wrote:
>
> Okay, I'm confused. I found it, in here:
> /Users//.virtualenvs//lib/python2.7/site-
> packages/django/contrib/auth/migrations
>
> Why are app related migrations being stored in this location?
>
> Cheers,
>
> Ed
>

 What? Migrations related to Django's auth app are, not surprisingly, 
 stored alongside the code to that app. Why does this puzzle you? 

>>>
>>> I guess it's because I thought that we could build migrations on the 
>>> development machines and then update the project on the production machine 
>>> and apply the migrations. Obviously this assumption was wrong and we need 
>>> to distribute the entire .virtualenv too... 
>>>
>>> Fine, if that's the way it is, that's the way it is, but to me this 
>>> seems odd because everything else in there is just something you 'pip 
>>> install' and I would not expect to mix 'user data' with 'installed 
>>> packages' like this. It actually seems like an unfortunate design decision 
>>> since it forces you - unless you try to be clever - to put django etc into 
>>> the repository... we did this before and shifting to 1.7 was more painful 
>>> as a result).
>>>
>>> Anyway, thanks for the reply!
>>>
>>> Cheers,
>>>
>>> Ed
>>>
>>

-- 
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 d

Re: Newbie operational error with Django db tables

2014-11-12 Thread Collin Anderson
Hello,

Very interesting. I wonder if the model isn't being noticed in syncdb 
because it's in models/downloads.py, and it's not referenced in 
models/__init__.py.

Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@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/3e22e841-bea4-4757-ae06-519f0956b719%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django auto fill recipient in Django_messages

2014-11-12 Thread Collin Anderson
Hello,

What does your form_class look like?

Thanks,
Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@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/6997aef4-f9ea-4cf0-8054-04382cc1ff6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django 1.7 - help with change in "Save as new" behavior when related inlines are marked to be deleted

2014-11-12 Thread Collin Anderson
Hello,

That does seem odd. Are you using a custom form or custom template at all?

There shouldn't be a delete box for unsaved items, right?

Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@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/2a388c5d-f4f8-4fbb-adc7-96f1c4080d1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Page reload hang using django (python 2.7 in linux)

2014-11-12 Thread Collin Anderson
Hello,

My guess is the web app is stuck doing some IO or waiting for a subprocess.

Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@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/768f3dfb-738e-4146-aa77-9c33797d738a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: HStoreField can't adapt type 'dict'

2014-11-12 Thread Collin Anderson
If anyone runs into this later, here's the ticket with the solution:
https://code.djangoproject.com/ticket/23776

-- 
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/fa827df7-abc4-41f6-b0b7-b947b2638396%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using a foreign key id value triggers `refer_to_missing_field` error on migrate

2014-11-12 Thread Collin Anderson
Hello,

You could try: ordering = ('rel__id',)

Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@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/1b499252-9639-4901-9019-0907eab3de95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Beginner needs help with models.py for a Survey like Website

2014-11-12 Thread Collin Anderson
Hello,

It seems to me you should merge your Picture and Collection model, right? 
because there's a collection of questions for each picture?

So I thought that I need additional fields in the Picture class to safe the 
> average score, but what if my question list changes? Then I need to update 
> the Picture class every time and add an additional field for each new 
> question. That doesn't make sense. I would need something like a Decorator 
> pattern - but I have no idea if this is possible in databases, or how to 
> model it.


It might make sense to save it on a "through" table in your many to many.

Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@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/7f4431b9-823e-4205-8a7b-d0158e48c3f0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


set the css class of a form widget based on the data

2014-11-12 Thread Michael
Hi,

The ``attrs`` attribute of a widget allows to define the html attributes. 
For example, setting it to ``widget.attrs['class'] = 'class1 class2'`` will 
add ``class="class1 class2"`` on the rendered widget.

However, how can I set them based on the data? I display an update form and 
I'd like to change the CSS class based on the data that is going to be 
displayed when the form is rendered.

Where could I check for the data in order to change the ``attrs`` property 
of the widget before it is rendered?

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/3569acd7-5bec-4df9-8960-4952b3fee8fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django bulk sms

2014-11-12 Thread Collin Anderson
Hello,

You may want to try the kannel mailing list.

http://www.kannel.org/lists.shtml

Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@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/d2a04b85-60dd-4f3a-8e5a-30c3646c419a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django and Ajax, Django not returning posted data.

2014-11-12 Thread Collin Anderson
Hello,

In your first method (non-json), try console.log(data) in the success 
function.

When you tried json, was there any other error in the console? What about 
the network tab?

Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@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/317a6e84-b9bd-4bd2-be3f-5494628977af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django expat error

2014-11-12 Thread Collin Anderson
Hello,

Interesting. Could you post more of the traceback?

Thanks,
Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@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/cc09138f-ec73-4aea-8c9a-ce7ee5f15287%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: geodjango application in rhel 6

2014-11-12 Thread Collin Anderson
Hello,

It could help to post a traceback if you are still running into the problem.

Thanks,
Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@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/57283e7c-46d0-46bd-99c9-2a6743039476%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I migrate models from one app to another with django 1.7 migrations?

2014-11-12 Thread Collin Anderson

>
> 2. I've moved my models to the new app but I have them using the tables 
> from the old app using Meta.db_table. How do I make migrations understand 
> what's going on and not try to delete my old tables? Once migrations gets 
> what's going on, how do I rename the old table so it fits the new app name 
> so I no longer need Meta.db_table?
>
Autodetecting changes to Meta.db_table was just added in django 1.7.1, so 
try that out if you haven't.

-- 
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/ba996a94-feae-4456-bc2d-89dbd1dd2440%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


moving existing django projects

2014-11-12 Thread Malik Rumi


Q: This is a ‘help me understand how this works / what it does’ question 
rather than a ‘help me I’m stuck’ question. I have an existing Django 
project I wanted to get on Heroku. I created a new site on Heroku, uploaded 
my project, and ran migrations. But all I have is a generic new, empty 
Django site. The Django admin knows nothing about my models. Now, granted, 
I have not yet put up my existing database but I expected it to at least 
create the tables for my models, which it did not. Of course they are in 
installed apps, but I did not run ‘startapp’ since the app already exists. 
So why didn’t this work? 

Or, should the question be: 'in the case of moving a pre-existing project, 
what do you do *instead *of 'startapp''?

Or maybe I have to run startapp anyway? Why?

-- 
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/5a5b7987-8c92-4522-861f-5c9d0871e8ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: 1.7 migrations: problem with renamed upload_to function on FileField

2014-11-12 Thread Markus Holtermann
Hey Hans,

As stated in the Docs 
(https://docs.djangoproject.com/en/1.7/topics/migrations/#historical-models)

References to functions in field options such as upload_to and 
limit_choices_to are serialized in migrations, so the functions will need 
to be kept around for as long as there is a migration referencing them. Any 
custom model fields will also need to be kept, since these are imported 
directly by migrations.


So, simply open the migration file that has the import to the old function 
and adjust the reference. Inside the CreateModel operation change

('file', models.FileField(upload_to=example.models.ex_upload_to)),

to

('file', models.FileField(upload_to=example.models.ex_upload_to_new)),

/Markus

On Wednesday, November 12, 2014 5:28:52 PM UTC+1, Hans Lawrenz wrote:
>
> I'm having a problem generating migrations after changing the function 
> used for the upload_to parameter on a FileField. After removing the old 
> function from my code and switching to using a closure to generate the 
> function used by upload_to I get the following exception upon running 
> makemigrations:
>
> AttributeError: 'module' object has no attribute 'story_image_url'
>
>
> I made a simple test using an empty app and just renaming the upload_to 
> function and get the same results because the existing migration references 
> the old function.
>
> Any suggestions on how to handle this beyond keeping a dummy function in 
> the code?
>
> Here's an example:
>
> original models.py:
> from django.db import models
> def ex_upload_to(instance, filename):
> return "foo"
> 
> class MyModel(models.Model):
> 
> file = models.FileField(upload_to=ex_upload_to)
>
>
>
> migration:
> from __future__ import unicode_literals
> from django.db import models, migrations
> import example.models
> 
> class Migration(migrations.Migration):
>dependencies = [
>]  
> 
>operations = [
>migrations.CreateModel(
> name='MyModel',
> fields=[
> ('id', models.AutoField(verbose_name='ID', 
> serialize=False, auto_created=True, primary_key=True)),
> ('file', 
> models.FileField(upload_to=example.models.ex_upload_to)),
> ],  
> 
> options={
> },  
> 
> bases=(models.Model,),
> ),  
> ]  
>
>
> new models.py:
> from django.db import models
> 
> def ex_upload_to_new(instance, filename):
> return "foo"
> 
> class MyModel(models.Model):
> file = models.FileField(upload_to=ex_upload_to_new)
>
>
>
>
>

-- 
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/8d0fac4b-24f9-44d4-970b-9222fed3c588%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


1.7 migrations: problem with renamed upload_to function on FileField

2014-11-12 Thread Hans Lawrenz
I'm having a problem generating migrations after changing the function used 
for the upload_to parameter on a FileField. After removing the old function 
from my code and switching to using a closure to generate the function used 
by upload_to I get the following exception upon running makemigrations:

AttributeError: 'module' object has no attribute 'story_image_url'


I made a simple test using an empty app and just renaming the upload_to 
function and get the same results because the existing migration references 
the old function.

Any suggestions on how to handle this beyond keeping a dummy function in 
the code?

Here's an example:

original models.py:
from django.db import models
def ex_upload_to(instance, filename):
return "foo"

class MyModel(models.Model):

file = models.FileField(upload_to=ex_upload_to)



migration:
from __future__ import unicode_literals
from django.db import models, migrations
import example.models

class Migration(migrations.Migration):
   dependencies = [
   ]  

   operations = [
   migrations.CreateModel(
name='MyModel',
fields=[
('id', models.AutoField(verbose_name='ID', 
serialize=False, auto_created=True, primary_key=True)),
('file', 
models.FileField(upload_to=example.models.ex_upload_to)),
],  

options={
},  

bases=(models.Model,),
),  
]  


new models.py:
from django.db import models

def ex_upload_to_new(instance, filename):
return "foo"

class MyModel(models.Model):
file = models.FileField(upload_to=ex_upload_to_new)




-- 
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/35287e93-91aa-4fbc-a872-875d78e0e0cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is django framework feasible for developing online LMS?

2014-11-12 Thread Aliane Abdelouahab
if you are planning to use a long opened connexion, you can 
check http://www.tornadoweb.org/en/stable/ it is easy, and you gonna like 
it, and it dont need a long learning curve, it has a templating engine like 
django.
so, good luck :)

Le mercredi 12 novembre 2014 08:20:22 UTC+1, Pradip Shahi a écrit :
>
> Hi everyone, I am new to Django web framework but familiar with python 
> programming.
> I am planning to develop an online Learning Management system for a 
> college(client). 
> LMS covers online course and learning system.
> So, is it worth choosing django rather than other like Ruby on Rails or 
> asp.net?
>
> 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/b34a1791-ae60-4647-b282-9f58dd847120%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is django framework feasible for developing online LMS?

2014-11-12 Thread Krishnakant Mane


I will recommend Django as the best for this kind of work.
There is Meta studio which does exactly that and it is developed in Django.
I suggest you go to www.gnowledge.org and see if you can find a link to 
the said project.

happy hacking.
Krishnakant. On 11/12/2014 07:42 PM, Avraham Serour wrote:

what kind of answer do you expect asking if django is better than X on a
django list?

If you are already familiar with python it is worth to use a python based
framework over something else you are not familiar with.
But this is only one piece of the puzzle, you still need a deployment
server, database and client side to worry about at least

On Wed, Nov 12, 2014 at 9:20 AM, Pradip Shahi 
wrote:


Hi everyone, I am new to Django web framework but familiar with python
programming.
I am planning to develop an online Learning Management system for a
college(client).
LMS covers online course and learning system.
So, is it worth choosing django rather than other like Ruby on Rails or
asp.net?

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/8baf79a5-befc-4e34-9bfc-6cf861062362%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/54639024.8070509%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is django framework feasible for developing online LMS?

2014-11-12 Thread Scot Hacker


On Wednesday, November 12, 2014 8:11:16 AM UTC-8, Ari Davidow wrote:
>
> I am curious as to why you would write an LMS from scratch, rather than 
> use an existing framework--edX uses Django and that code is open-sourced 
> and available. Other open source possibilities, not relying on Django, 
> include Moodle and Sakai.
>

The nine months I spent working on a Sakai project were among the very 
worst of my professional development career. And it's virtually a dead 
project now. Now I'm working part-time on a large Moodle installation and 
finding it incredibly frustrating. You know how they say PHP has a tendency 
toward sprawling spaghetti code? Moodle feels like the poster child for 
that tendency. It's badly written, badly documented, the community is full 
of people taking wild guesses, plugins are half-baked, and lots of people 
are hacking core to make it do what they need it to do.

A lot of the complexity and mess in these products comes from their need to 
be all things to all people. Everything is overly abstracted, and 90% of 
the features you'll never use. Meanwhile you bear the brunt of all that 
baggage and complexity. I am currently lobbying the .edu I work for to 
replace a Moodle installation with a custom Django system that will do 
exactly the things we need it to do and nothing more. To discard the 
complexity and baggage and replace it with clean data modeling and known 
workflows that aren't "black box." Case in point: I spent around a month 
getting the Moodle course enrollment system to behave with a PHP script. 
Then I wrote a similar one for a separate Django system on the side. The 
Django version worked the first time and was literally 1/0 the size, in 
lines of code.

./s

>
>

-- 
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/6584d076-0aea-47a3-86d7-4ef0a3cb5f57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is django framework feasible for developing online LMS?

2014-11-12 Thread Scot Hacker


On Wednesday, November 12, 2014 7:54:18 AM UTC-8, Tom Evans wrote:
>
>
> There is basically no difference between any web framework in terms of 
> features, so pick whichever one you want that is in the language you 
> know or wish to learn. 
>
>
Frameworks may all have roughly the same features, but that doesn't mean 
they're equally effective to work in. Some frameworks are just better 
designed than others, or feel more intuitive, or have a better ecosystem, 
etc. In my opinion, the choice of a framework and its ecosystem is far more 
important than the particular language it's in. I love Python, but I love 
Django even more (IOTW I'd choose Django for what it is even if it wasn't 
written in Python). Django makes complex feature development easy, compared 
to other systems I've worked with. 
 

> As to whether you can build  in , it would 
> be a pretty bad  if you cannot build whatever  type> you want in it. 
>

Agreed.

./s
 

>
> 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/5ea7726d-3551-417f-859b-f7b24ed189ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is django framework feasible for developing online LMS?

2014-11-12 Thread Ari Davidow
I am curious as to why you would write an LMS from scratch, rather than use
an existing framework--edX uses Django and that code is open-sourced and
available. Other open source possibilities, not relying on Django, include
Moodle and Sakai.

Creating a professional environment that supports the presentation of
materials to students, appropriately controls access, facilitates
discussion, and facilitates grading (not to mention supports creation,
editing, presentation of quizzes and other smaller learning elements) is
messy. You could easily end up putting a lot of your client's time and
money into re-inventing and re-discovering the already-extant.

May be worth looking at how existing OS LMS's work, reviewing the client's
needs from that perspective, looking at what would get you to an initial
release most easily and sustainably, and then deciding on platform.

ari

On Wed, Nov 12, 2014 at 2:20 AM, Pradip Shahi 
wrote:

> Hi everyone, I am new to Django web framework but familiar with python
> programming.
> I am planning to develop an online Learning Management system for a
> college(client).
> LMS covers online course and learning system.
> So, is it worth choosing django rather than other like Ruby on Rails or
> asp.net?
>
> 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/8baf79a5-befc-4e34-9bfc-6cf861062362%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/CAF%2BxBDVCQsRmpjbjtnfrhR7vN9nUF7K3WGQiR0CivYjP_ndN3A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is django framework feasible for developing online LMS?

2014-11-12 Thread Tom Evans
On Wed, Nov 12, 2014 at 7:20 AM, Pradip Shahi  wrote:
> Hi everyone, I am new to Django web framework but familiar with python 
> programming.
> I am planning to develop an online Learning Management system for a 
> college(client).
> LMS covers online course and learning system.
> So, is it worth choosing django rather than other like Ruby on Rails or 
> asp.net?
>

There is basically no difference between any web framework in terms of
features, so pick whichever one you want that is in the language you
know or wish to learn.

As to whether you can build  in , it would
be a pretty bad  if you cannot build whatever  you want in it.

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/CAFHbX1K2CivbGYu3E4sg4ZpDhWKSP%2BZ5UYKrnp6yrZjf2R-7Jg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Issue in Django 1.7.1 with __unicode__ and admin site?

2014-11-12 Thread Arjan de Knegt
Thanks all, my problem solved and I gained some more knowledge on python 3 
specifics.

-- 
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/444d57e0-98b1-482b-88f2-75f8aa39e9dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


modify attribute on a model based on the other attributes when it is added: model.clean method?

2014-11-12 Thread Michael
Hi,

I would like to modify an attribute on a model based on the other 
attributes when it is added from the admin or elsewhere.

For example:

Model A: 
has FK to Model B
has FK to Model C

Model B: 
has FK to Model C


When I create a Model A, I choose a Model B so I'd like the FK to Model C 
to be set automatically based on the FK to Model C that already exists on 
Model B.

I found the ``Model.clean`` method 
(https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.clean)
 
but it says that it is not invoked when you call your model’s save() method 
so when is it invoked? I am a bit confused about the purpose of this method 
then.

I tried the clean method and I was able to make it work after some issues 
but I am wondering whether that's the best way to do it?

Thanks
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/72e88e1d-3ed5-4a81-8ee2-4f3b724552dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Looking for Django Python Developers to build Strong Application

2014-11-12 Thread Chetan Salvi
 Hi Ankit,

 I will refer our own company Lotus Intelligent Systems which is 
progressing as start up Indian based company.

We had developed many web applications in python using django.

You can visit our website www.lotusintelligentsystems.com.

Thanks

Regards
chetan salvi

-- 
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/fd9e6542-15fa-4d7b-83b5-2d2204961fbc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is django framework feasible for developing online LMS?

2014-11-12 Thread Avraham Serour
what kind of answer do you expect asking if django is better than X on a
django list?

If you are already familiar with python it is worth to use a python based
framework over something else you are not familiar with.
But this is only one piece of the puzzle, you still need a deployment
server, database and client side to worry about at least

On Wed, Nov 12, 2014 at 9:20 AM, Pradip Shahi 
wrote:

> Hi everyone, I am new to Django web framework but familiar with python
> programming.
> I am planning to develop an online Learning Management system for a
> college(client).
> LMS covers online course and learning system.
> So, is it worth choosing django rather than other like Ruby on Rails or
> asp.net?
>
> 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/8baf79a5-befc-4e34-9bfc-6cf861062362%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/CAFWa6tKSo0nbsrjOMEzZnD3nYfsvxQxrxhCC2DrgJUC_rdDMdw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How to keep backwards campabilities when upgradeing django to 1.7

2014-11-12 Thread Victor Liu
Hi all

Considering that how much work will be done when upgrading our project from 
django 1.5 to django 1.7, I'd like to ask you guy some concerns.


1. The project structure are quite different between 1.5 and 1.7, what are 
careful points when doing this?
2. We use south, how do I keep backwards compatibilities, in other words, 
is that possible the south migration files still useful for rolling back 
after upgrading it to django 1.7? 
3. Any other things I must consider when upgrade our project?

Any suggestion and resource about this will be appreciated.
Thanks in advance.

Best Regards
Victor Liu

-- 
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/9a44b6e7-d836-4fd3-9bb3-3849a5500b7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Is django framework feasible for developing online LMS?

2014-11-12 Thread Pradip Shahi
Hi everyone, I am new to Django web framework but familiar with python 
programming.
I am planning to develop an online Learning Management system for a 
college(client). 
LMS covers online course and learning system.
So, is it worth choosing django rather than other like Ruby on Rails or asp.net?

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/8baf79a5-befc-4e34-9bfc-6cf861062362%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to test an application that's using a legacy database

2014-11-12 Thread David Palao
2014-11-12 0:25 GMT+01:00 Carl Meyer :
> Hi David,
>
> On 11/11/2014 08:37 AM, dpalao.pyt...@gmail.com wrote:
>> Dear Carl,
>>
>> Thank you for the answer.
>>
>> On Tuesday, November 11, 2014 3:13:18 PM UTC+1, Carl Meyer wrote:
>>
>> Hi David,
>>
>> On 11/11/2014 07:01 AM, dpalao...@gmail.com  wrote:
>> > I see your point. You might be right, but it is not clear to me
>> how to
>> > do it and if it would work: I have already tried to subclass
>> > DiscoverRunner to modify its behaviour with little success.
>>
>> If there are specific aspects of "how to do it" that are confusing to
>> you, I could try to clarify. Or if you try it and have specific
>> problems.
>>
>>
>> Well, I never worked with sql directly. And as I said in my post when I
>> tried to subclass  DiscoverRunner I got the impression that it is not
>> straightforward (at least for my limited experience with Django).
>>
>> > Another problem that I see: it is not an homogenous approach. I mean,
>> > the models are created from the production database. Now I create an
>> > independent database for testing. Of course, you will tell me that I
>> > have to follow the TDD approach to the end: for the code that creates
>> > the testing database too! And I would agree. But it is clearly a
>> bit too
>> > complicated.
>>
>> I'm afraid I am quite confused by this paragraph.
>>
>> I don't know what you mean by "not an homogenous approach".
>>
>> And I don't know what you mean by "the models are created from the
>> production database."
>>
>> And I don't know what you mean by "an independent database for
>> testing."
>> Django already creates a new database for each test run. I'm not
>> suggesting creating any additional database beyond that, just running
>> some SQL to create your legacy (un-managed) tables in the testing
>> database.
>>
>> The code that creates the testing database will be exercised at the
>> start of every test run, and if it's not working your tests will fail
>> because the legacy tables are not created. Personally, I'd consider
>> that
>> adequate; I wouldn't write any additional tests for that code.
>>
>>
>>  I created the models by running "inspectdb". I see that as a (logical)
>> link between the models and the tables. Perhaps not the standard link,
>> but they are related. That is what I meant by "the models are created
>> from the production database".
>
> I see, that makes sense.
>
>> Now your suggestion is to create some tables from scratch. By hand. This
>> is what I mean by "not an homogeneous approach", because I don't see a
>> logical link between the models and the testing database. The testing
>> database is created by me. (Or by Django, then I take control to create
>> the tables, then I return control to Django -- if this is what you suggest).
>
> Sorry, I didn't fully explain this part of my suggestion. I would not
> create the SQL for those tables "by hand" - I would do it via a dump of
> the SQL schema from the actual production tables.
>
>> But actually I think your solution makes a lot of sense. At the
>> beginning I wanted Django to create the testing database along with the
>> tables automatically. And you probably are right and the SQL code to
>> create the tables is absolutely trivial, but for me it is not.
>> So I tried also something slightly different. As the database already
>> exists, I think it would make sense if I also the testing database
>> exists prior to testing.
>> What I just did was:
>> I created the testing database simply with a command like
>>
>> mysqldump -u user --password='xxx' -h localhost -d production_db | mysql
>> -h localhost -u user --passwor='xxx' -Dtest_db
>
> So this is close to my suggestion. But rather than creating the entire
> DB (including managed models too), I would send the dump to a SQL file
> instead:
>
> mysqldump -u user --password='xxx' -h localhost -d production_db >
> schema.sql
>
> And then edit schema.sql to remove any tables for normal managed models,
> leaving only the table definitions for the unmanaged (legacy) tables.
> (You might also add `--no-data`, depending whether you want your legacy
> tables to also be prepopulated with data for your tests).
>
> Then you can allow Django to create its test database normally, and run
> migrations to create tables for your managed models; you just have to
> additionally run `schema.sql` to add in the un-managed tables.
>
> (It's possible that your approach of pre-creating the entire test DB
> could just work, with no need to subclass DiscoverRunner at all, by
> using the --keepdb option to manage.py test; but that option only exists
> in the Django development version, so you probably don't have it.)
>
>> Again, I must subclassing DiscoverRunner to have a chance to succeed
>> (need to by-pass db creation), and actually Django complains if I don't
>> do that.
>> So, I subclassed the DiscoverRunner

Re: Django + Database Connections

2014-11-12 Thread Edward Armes
HI guys,

Thanks for your responses, they have indeed answered all my questions
pretty much as I was mainly looking for information on how to modify how
Django accesses it's ORM layer. However from your answer it seems that it
would be better that I do it at the model layer. I apologize for being so
vague in my question it was semi-deliberate as I wanted to avoid people
posting application specific solutions like "Use module X and do Y" and
often when you ask questions reguarding internals on open-source projects
and other places (i.e. Stack Overflow) you normaly get a load people
responding with "why?" which for understandable reasons I wanted to avoid.

To follow on from this I have a few more quick questions:-

- If my understanding is correct the Django admin interface uses the model
layer? If so while learning Django I remember reading (although I can't
find the link now) that if you use a model that doesn't use Django database
layer the admin code doesn't work? if this is the case why so?

- Secondly would I be correct in thinking that by having asynchronous
models it would break the default forms and views lthat are included ike
the wonderful Admin package?

Many Thanks.

Edward

On Wed, Nov 12, 2014 at 6:09 AM, Kakar Nyori  wrote:

> Very nicely explained.
>
> On Wed, Nov 12, 2014 at 2:55 AM, Russell Keith-Magee <
> russ...@keith-magee.com> wrote:
>
>> Hi Edward,
>>
>> On Tue, Nov 11, 2014 at 12:30 AM, Edward Armes 
>> wrote:
>>
>>> Hi there,
>>>
>>> I am currently looking at Django for a personal project. While I
>>> understand how a lot of it works I can't wrap my head around how the actual
>>> DB querying is done specifically what part of Django actually looks at the
>>> database (I'm not talking about Manager, Models or Querysets, but the
>>> actual parts of Django that use the ORM's to get data from the database
>>> itself).
>>>
>>> If a reason is required without going into detail on my current
>>> half-baked idea, I'm specifically looking how to handle database operations
>>> that have a significant return time by marrying asynchronous environments
>>> with synchronous ones. While it may be more efficant to use a non-Django
>>> database handler. For now I want to look into using the Django framework
>>> without needing additional imports.
>>>
>>>
>> It's not that a *reason* is required - it's that it's not entirely clear
>> what you're asking for.
>>
>> The thing is, Django *itself* doesn't do a lot of querying - Django is a
>> template system, and a forms layer, and a database ORM, all nicely
>> integrated, so you can easily compose the pieces to do something useful.
>> There are places where the forms layer will issue queries (e.g., if you
>> want to display a form that has a  representing the available
>> options from a model), but that's really at the level of "give me a
>> queryset that represents the options I want to display".
>>
>> The only part of Django *itself* that "uses" Django is the contents of
>> the contrib apps - most importantly, contrib.admin, but there are others.
>>
>> The idea of marrying async and synchronous environments isn't a new one -
>> it was the subject of a Google Summer of Code project this year, the result
>> of which will hopefully be committed to trunk for 1.8. The core of that
>> project was to formalise the API around Django's model layer so that you
>> can write a "duck typed" object that will be a substitute for a Django
>> model (subject to certain constraints and limitations). Search the
>> Django-Developer archive for "Meta Refactor" if you want more details.
>> However, that won't let you get away "without needing additional imports" -
>> at some point, you're going to need to import your async layer, because
>> Django doesn't have one.
>>
>> I don't know if any of this helps... hopefully it does :-)
>>
>> Yours,
>> Russ Magee %-)
>>
>>  --
>> 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/CAJxq848_Oy_oWhLnu5h8dfgT1MW8CKny_ZQKZcQ4nCdO9_W%2B5g%40mail.gmail.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> 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/QT27WcWMlLM/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post 

Re: Issue in Django 1.7.1 with __unicode__ and admin site?

2014-11-12 Thread Leandro Zanuz
Don't do that, django recomends to use "python_2_unicode_compatible"
decorator.

https://docs.djangoproject.com/en/dev/topics/python3/#str-and-unicode-methods

2014-11-11 21:08 GMT-02:00 Mike Dewhirst :

> On 12/11/2014 7:26 AM, Jorge Andrés Vergara Ebratt wrote:
>
>> When you are in Python3 you don't use __unicode__ you use __str__
>>
>
> You can leave __unicode__ in place for Python 2.x and add ...
>
> def __str__(self):
> return self.__unicode__()
>
> ... to satisfy Python 3.x at the same time
>
>
>> On Tue, Nov 11, 2014, 3:14 PMÂ Arjan de Knegt > > wrote:
>>
>> I am using Django 1.7.1 with python 3.4.0 for my latest project.
>> I am working on a model called Song. In the admin site all object
>> that I add show as "Song object" where I would expect the title of
>> the Song. I have added __unicode__ to the model. is there something
>> I miss or are things changed in Django 1.7? Below the model and what
>> is shown in the admin site
>>
>> _Model:_
>> class Song(models.Model):
>> Â Â Â  title = models.CharField(max_length=100, verbose_name =
>> 'Titel')
>> Â Â Â  author = models.CharField(max_length=100, verbose_name =
>> 'Auteur')
>> Â Â Â  genre = models.ForeignKey('Genre', to_field='genre')
>> Â Â Â  featured = models.BooleanField(default = False, verbose_name
>> = 'featured')
>> Â Â Â  song_order = models.IntegerField()
>> Â
>> Â Â Â  class Meta:
>> Â Â Â Â Â Â Â  verbose_name = _('Song')
>> Â Â Â Â Â Â Â  verbose_name_plural = _('Songs')
>> Â Â Â Â Â Â Â  ordering = ['song_order']
>>
>> Â Â Â  def __unicode__(self):
>> Â Â Â Â Â Â Â  return self.title
>>
>> _Shown in Admin site:_
>>
>> Song
>> Song object 
>> Song object 
>> Song object 
>> Song object 
>>
>>
>> --
>> 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/01cc75ba-
>> 302c-4066-9e4a-fbdc4f3504ea%40googlegroups.com
>> > 302c-4066-9e4a-fbdc4f3504ea%40googlegroups.com?utm_medium=
>> email&utm_source=footer>.
>> 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/CAAeX05F%
>> 3DOUMswk2KQfdLvkrEGkQ9PbztLYBbC44T66WU%2BAYMYw%40mail.gmail.com
>> > 3DOUMswk2KQfdLvkrEGkQ9PbztLYBbC44T66WU%2BAYMYw%40mail.gmail.
>> com?utm_medium=email&utm_source=footer>.
>> 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/546296F2.5060201%40dewhirst.com.au.
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Enviado via UCSMail.

-- 
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/CACctwSgtbozLQiC_Vbn%2B4_%3DkSyOS5_ue1eTLZtBb5OCCWbZzvg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/opto

Re: Import Error Module

2014-11-12 Thread Erik Cederstrand
> Den 12/11/2014 kl. 01.39 skrev Niall :
> 
> Hi Erik, yes it is installed but it comes up with the following error when I 
> try to run the server again.
> 
> I know that it is something simple like changing the PYTHONPATH so if you 
> could advise on why it is happening and how I should proceed that would be 
> great. 

manage.py can't find your settings.py file.

Your project layout is hopefully something like:

-manage.py
-my_project
 |
  - settings.py


In this case, manage.py should contain the line:

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_project.settings')


Erik

-- 
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/84EBF692-CCF8-4AB3-92A3-5E036B63F3EF%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.