Re: SQL Server Support - Does it Exist

2015-04-29 Thread Alex-droid AD
We try to use django-pyodbc on CentOS (python 2.7 + Django 1.8, connection 
to MS SQL Server 2012)
While running 'migrare' I get the same error as mentioned above:
'django_pyodbc' isn't an available database backend

Can't understand what has been done wrong...

On Sunday, March 24, 2013 at 5:14:55 PM UTC+3, Michael Manfre wrote:
>
> Although there is no official support for SQL Server, there are two 
> available backends to choose from; django-mssql and django-pyodbc. There 
> has also been some recent discussion on the django-developers mailing list 
> about SQL Server's support and the idea of having officially recognized 
> extensions (see [1]).
>
> [1] 
> https://groups.google.com/d/msg/django-developers/O-g06EM6XMM/Y7PcP5VUzYMJ
>
> I'm the maintainer of django-mssql and have been using it on 
> http://www.src.org since Django 1.1 and has upgrade to the Django stable 
> version shortly after each release. We're currently on Django 1.4.x and 
> plan on upgrading to Django 1.5 in the next few months. Django-mssql 
> requires pywin32 and must be run on a Windows server. During the ~1.5 years 
> between your post and the previous one in this topic, the django-mssql 
> project has made a lot of improvements, including better documentation [2].
>
> [2] http://django-mssql.readthedocs.org/en/latest/
>
> If your web servers are non-windows, then you can use django-pyodbc. The 
> google code hosted project [3] is a bit out of date, but there is a 
> slightly newer fork available on GitHub [4].
>
> [3] https://code.google.com/p/django-pyodbc/
> [4] https://github.com/avidal/django-pyodbc
>
> Regards,
> Michael Manfre
>
> On Saturday, March 23, 2013 12:35:08 AM UTC-4, Liang wrote:
>>
>> Sadly, django doesn't support sql server officially is the only stopper 
>> for me to adopt django. 
>>
>> On Friday, 15 July 2011 09:07:23 UTC+8, Russell Keith-Magee wrote:
>>>
>>> On Fri, Jul 15, 2011 at 6:03 AM, bruno desthuilliers
>>>  wrote:
>>> >
>>> >
>>> > On 14 juil, 23:15, Python_Junkie 
>>> > wrote:
>>> >> I have searched for the drivers to use the syncdb utility with MS SQL
>>> >> Server but have been unsuccessful.
>>> >
>>> > https://docs.djangoproject.com/en/1.3/ref/databases/
>>> >
>>> > Django doesn't support MS SQL.
>>>
>>> Django doesn't provide *official* support MSSQL. However, we do have a
>>> supported backend API, and there are several third-party projects that
>>> implement MS SQL support [1]. I can't comment on their completeness or
>>> stability, but the projects exist.
>>>
>>> [1] 
>>> https://docs.djangoproject.com/en/1.3/ref/databases/#using-a-3rd-party-database-backend
>>>
>>> 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/b217f87a-19d3-42a2-aa02-7f0faaee71e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Require code explaination

2015-04-29 Thread Anubhav Kaushik
response = HttpResponse()

protected = settings.PROTECTED_AUDIO_ROOT + path

logger.info('Protected path: %s', protected)

response["X-Accel-Redirect"] = protected

response["Content-Type"] = "audio/mpeg"

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/f59471d6-1baa-4a36-9d3c-327684049d65%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to get the complement in django?

2015-04-29 Thread 田福顿
I want to connect to tables than get their complment, but I don't know how 
to do it? Plaea give me some suggestion. I have wasted two days in this 
problem.BTW this way didn't work:Django: Getting complement of queryset 


-- 
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/b8674d0f-ce61-401b-bb41-4b6fc9131ba1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


clear database (drop all tables)

2015-04-29 Thread lars van Gemerden
Hi all,

Is there a simple programmatic way to drop all tables in the database (e.g. 
for testing purposes), also without input prompts?

Cheers, Lars

-- 
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/0ebbbdb5-f9ad-437b-baaa-9a39358704cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django "Add to Cart"

2015-04-29 Thread Hasit Mamtora
Please help me in building* Add to Cart *module for my E-commerce portal.
I am not able to  build one.

Suppose I include *django-carton 
* app to my project than how do 
i proceed further.
Can anyone help me in my problem?

-- 
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/fd837e28-67b1-4fc1-83e8-31f0cb3627c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get the complement in django?

2015-04-29 Thread Tom Evans
On Wed, Apr 29, 2015 at 11:06 AM, 田福顿  wrote:
> I want to connect to tables than get their complment, but I don't know how
> to do it? Plaea give me some suggestion. I have wasted two days in this
> problem.BTW this way didn't work:Django: Getting complement of queryset

That is how to do it. What doesn't work? Show an example..

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/CAFHbX1%2Bkr%2BnFne8neMc%3D9C8e-GcnxAv2CCQ1Fs4NiCkpQ_fiLg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to get the complement in django?

2015-04-29 Thread 田福顿


在 2015年4月29日星期三 UTC+8下午6:32:09,Tom Evans写道:
>
> On Wed, Apr 29, 2015 at 11:06 AM, 田福顿 > 
> wrote: 
> > I want to connect to tables than get their complment, but I don't know 
> how 
> > to do it? Plaea give me some suggestion. I have wasted two days in this 
> > problem.BTW this way didn't work:Django: Getting complement of queryset 
>
> That is how to do it. What doesn't work? Show an example.. 
>
> Tom 
>

this is my code 
if StudyRecord.objects.filter(id = i_d ).exists():
current=StudyRecord.objects.get(id = i_d )
if PersonalRecord.objects.filter(book = current.book,user_id = 
current.id).exists():
p_r = PersonalRecord.objects.filter(book = current.book,id 
= i_d)
for iterm in p_r:
words = WordBase.objects.filter(belong = current.book)
new_words=WordBase.objects.filter(belong = 
current.book).exclude(number__in=p_r.values_list('number', flat=True))[:1]
for single_words in new_words: 
u1 = PersonalRecord(user_id = request.user.id,begtime= 
time.time(),

endtime="",lasttime="",times = 0, status = 0,
number = 
single_words.number,book = single_words.belong,
  ) 
u1.save()
else:
new_words = WordBase.objects.filter(belong = current.book 
)[:5]
return HttpResponse("fail")
for single_words in new_words:  
u1 = PersonalRecord(user_id = request.user.id,begtime= 
time.time(),
endtime="",lasttime="",times = 1, 
status = 0,
number = single_words.number,book = 
single_words.belong,)   
u1.save()

but, it didn't work, it still save the record that the database already have
 

-- 
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/edc37582-c299-47d9-9d86-97ceab2de53a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: "RuntimeError: Error creating new content types."

2015-04-29 Thread Shubham Goyal
Facing the same problem. Any leads..??

On Saturday, April 18, 2015 at 2:38:56 AM UTC+5:30, Christophe Pettus wrote:
>
> Well, django_content_type.name definitely in my database. :)  This is a 
> project that was migrated from 1.6. 
>
> The underlying exception was a null value complaint about 
> django_content_type.name; it appears as though (on the production 
> database) it thought that the migration to remove had been applied, but in 
> fact had not been. 
>
> On Apr 17, 2015, at 1:25 PM, Tim Graham > 
> wrote: 
>
> > The contenttypes name column was removed in Django 1.8. Could you 
> retrieve the underlying exception before the RuntimeError is raised? 
> > 
> > On Friday, April 17, 2015 at 2:55:07 PM UTC-4, Christophe Pettus wrote: 
> > Digging into this a bit more, the specific exception is that it is 
> trying to insert a contenttypes row with a null 'name' value. 
> > 
> > The code in question is doing a get_or_create() on the contenttype 
> object.  I assume it should be picking up the name from the name @property 
> on the ContentType model, but I don't see that ever actually being called. 
> > 
> > 
> > On Apr 17, 2015, at 11:24 AM, Christophe Pettus  
> wrote: 
> > 
> > > On Django 1.8, I'm encountering this error when attempting to apply 
> migrations on the production system.  What's interesting is that it works 
> fine on the dev system, and inspecting the django_migrations table, I don't 
> see any (meaningful) differences between them (error text below). 
> > > 
> > > There was a model added to the "catalog" application which is not 
> being created in django_content_type. 
> > > 
> > > Manually migrating contenttypes individually generates the same error. 
> > > 
> > > -- 
> > > 
> > > $ python manage.py migrate 
> > > Operations to perform: 
> > >  Synchronize unmigrated apps: staticfiles, util, treebeard, messages, 
> office 
> > >  Apply all migrations: info, customers, sessions, admin, contenttypes, 
> auth, sites, catalog, coming_soon, orders 
> > > Synchronizing apps without migrations: 
> > >  Creating tables... 
> > >Running deferred SQL... 
> > >  Installing custom SQL... 
> > > Running migrations: 
> > >  Rendering model states... DONE 
> > >  Applying auth.0006_require_contenttypes_0002... OK 
> > > Traceback (most recent call last): 
> > >  File "manage.py", line 10, in  
> > >execute_from_command_line(sys.argv) 
> > >  File 
> "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 338, in execute_from_command_line 
> > >utility.execute() 
> > >  File 
> "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 330, in execute 
> > >self.fetch_command(subcommand).run_from_argv(self.argv) 
> > >  File 
> "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/base.py",
>  
> line 390, in run_from_argv 
> > >self.execute(*args, **cmd_options) 
> > >  File 
> "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/base.py",
>  
> line 441, in execute 
> > >output = self.handle(*args, **options) 
> > >  File 
> "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py",
>  
> line 225, in handle 
> > >emit_post_migrate_signal(created_models, self.verbosity, 
> self.interactive, connection.alias) 
> > >  File 
> "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/sql.py",
>  
> line 280, in emit_post_migrate_signal 
> > >using=db) 
> > >  File 
> "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py",
>  
> line 201, in send 
> > >response = receiver(signal=self, sender=sender, **named) 
> > >  File 
> "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py",
>  
> line 82, in create_permissions 
> > >ctype = ContentType.objects.db_manager(using).get_for_model(klass) 
> > >  File 
> "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/contrib/contenttypes/models.py",
>  
> line 78, in get_for_model 
> > >"Error creating new content types. Please make sure contenttypes " 
> > > RuntimeError: Error creating new content types. Please make sure 
> contenttypes is migrated before trying to migrate apps individually. 
> > > -- 
> > > -- Christophe Pettus 
> > >   x...@thebuild.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...@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/84FEBC7D-9A57-47FA-9429-A834A2

Re: Require code explaination

2015-04-29 Thread François Schiettecatte
Which part do you mean? The 'X-Accel-Redirect’ ? 

François

> On Apr 29, 2015, at 6:08 AM, Anubhav Kaushik  wrote:
> 
> response = HttpResponse()
> 
> protected = settings.PROTECTED_AUDIO_ROOT + path
> 
> logger.info('Protected path: %s', protected)
> 
> response["X-Accel-Redirect"] = protected
> 
> response["Content-Type"] = "audio/mpeg"
> 
> 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/f59471d6-1baa-4a36-9d3c-327684049d65%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/5D141546-4D98-4ADF-B3C6-CC5D0061DC43%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Require code explaination

2015-04-29 Thread Anubhav Kaushik
yes francois ,when i searched the term ,all i got was links related to 
nginx.

On Wednesday, April 29, 2015 at 4:55:58 PM UTC+5:30, François Schiettecatte 
wrote:
>
> Which part do you mean? The 'X-Accel-Redirect’ ? 
>
> François 
>
> > On Apr 29, 2015, at 6:08 AM, Anubhav Kaushik  > wrote: 
> > 
> > response = HttpResponse() 
> > 
> > protected = settings.PROTECTED_AUDIO_ROOT + path 
> > 
> > logger.info('Protected path: %s', protected) 
> > 
> > response["X-Accel-Redirect"] = protected 
> > 
> > response["Content-Type"] = "audio/mpeg" 
> > 
> > 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...@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/f59471d6-1baa-4a36-9d3c-327684049d65%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/b29c48fc-cb9d-49dd-869f-140afd5d1b6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Require code explaination

2015-04-29 Thread François Schiettecatte
I found this page which was pretty clear I think:

http://wiki.nginx.org/XSendfile
 
Looks like an nginx directive to serve a file as the content of the response. 

F.

> On Apr 29, 2015, at 7:28 AM, Anubhav Kaushik  wrote:
> 
> yes francois ,when i searched the term ,all i got was links related to nginx.
> 
> On Wednesday, April 29, 2015 at 4:55:58 PM UTC+5:30, François Schiettecatte 
> wrote:
> Which part do you mean? The 'X-Accel-Redirect’ ? 
> 
> François 
> 
> > On Apr 29, 2015, at 6:08 AM, Anubhav Kaushik  wrote: 
> > 
> > response = HttpResponse() 
> > 
> > protected = settings.PROTECTED_AUDIO_ROOT + path 
> > 
> > logger.info('Protected path: %s', protected) 
> > 
> > response["X-Accel-Redirect"] = protected 
> > 
> > response["Content-Type"] = "audio/mpeg" 
> > 
> > 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...@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/f59471d6-1baa-4a36-9d3c-327684049d65%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/b29c48fc-cb9d-49dd-869f-140afd5d1b6d%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/D931862C-ED51-4705-95B1-318BDBEAFF8C%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Require code explaination

2015-04-29 Thread Anubhav Kaushik
 but i am not running ny nginx server , m just running default wsgi server 
with django ,and files are still served file ,can you explain how that is 
happening?

On Wednesday, April 29, 2015 at 5:10:56 PM UTC+5:30, François Schiettecatte 
wrote:
>
> I found this page which was pretty clear I think: 
>
> http://wiki.nginx.org/XSendfile 
>   
> Looks like an nginx directive to serve a file as the content of the 
> response. 
>
> F. 
>
> > On Apr 29, 2015, at 7:28 AM, Anubhav Kaushik  > wrote: 
> > 
> > yes francois ,when i searched the term ,all i got was links related to 
> nginx. 
> > 
> > On Wednesday, April 29, 2015 at 4:55:58 PM UTC+5:30, François 
> Schiettecatte wrote: 
> > Which part do you mean? The 'X-Accel-Redirect’ ? 
> > 
> > François 
> > 
> > > On Apr 29, 2015, at 6:08 AM, Anubhav Kaushik  
> wrote: 
> > > 
> > > response = HttpResponse() 
> > > 
> > > protected = settings.PROTECTED_AUDIO_ROOT + path 
> > > 
> > > logger.info('Protected path: %s', protected) 
> > > 
> > > response["X-Accel-Redirect"] = protected 
> > > 
> > > response["Content-Type"] = "audio/mpeg" 
> > > 
> > > 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...@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/f59471d6-1baa-4a36-9d3c-327684049d65%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...@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/b29c48fc-cb9d-49dd-869f-140afd5d1b6d%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/e158ec09-020a-4b80-9913-c0e2c3eccc8a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Require code explaination

2015-04-29 Thread François Schiettecatte
You need to be a little more specific about what the context is, and what you 
are observing, rather than just plastering up some code.

- Is this code in an app you are working with ? Did you write this code ?

- Is the audio file being served by your application through the  default wsgi 
server included in django?

F.

> On Apr 29, 2015, at 7:55 AM, Anubhav Kaushik  wrote:
> 
>  but i am not running ny nginx server , m just running default wsgi server 
> with django ,and files are still served file ,can you explain how that is 
> happening?
> 
> On Wednesday, April 29, 2015 at 5:10:56 PM UTC+5:30, François Schiettecatte 
> wrote:
> I found this page which was pretty clear I think: 
> 
> http://wiki.nginx.org/XSendfile 
>   
> Looks like an nginx directive to serve a file as the content of the response. 
> 
> F. 
> 
> > On Apr 29, 2015, at 7:28 AM, Anubhav Kaushik  wrote: 
> > 
> > yes francois ,when i searched the term ,all i got was links related to 
> > nginx. 
> > 
> > On Wednesday, April 29, 2015 at 4:55:58 PM UTC+5:30, François Schiettecatte 
> > wrote: 
> > Which part do you mean? The 'X-Accel-Redirect’ ? 
> > 
> > François 
> > 
> > > On Apr 29, 2015, at 6:08 AM, Anubhav Kaushik  
> > > wrote: 
> > > 
> > > response = HttpResponse() 
> > > 
> > > protected = settings.PROTECTED_AUDIO_ROOT + path 
> > > 
> > > logger.info('Protected path: %s', protected) 
> > > 
> > > response["X-Accel-Redirect"] = protected 
> > > 
> > > response["Content-Type"] = "audio/mpeg" 
> > > 
> > > 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...@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/f59471d6-1baa-4a36-9d3c-327684049d65%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...@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/b29c48fc-cb9d-49dd-869f-140afd5d1b6d%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/e158ec09-020a-4b80-9913-c0e2c3eccc8a%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/13BF64E2-3B83-4100-9FA1-DAFCDE8A0676%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Require code explaination

2015-04-29 Thread Anubhav Kaushik
yes i am working on this code but  i havnt wrote this code otherwise i 
would not have required the explaination i guess.

and for your second question , i am not sure coz  as you said it looked 
like nginx directive , but i am running it on default wsgi server included 
in django . so i am asking how wsgi server is serving what a nginx is 
supposed to serve?

On Wednesday, April 29, 2015 at 5:35:26 PM UTC+5:30, François Schiettecatte 
wrote:
>
> You need to be a little more specific about what the context is, and what 
> you are observing, rather than just plastering up some code. 
>
> - Is this code in an app you are working with ? Did you write this code ? 
>
> - Is the audio file being served by your application through the  default 
> wsgi server included in django? 
>
> F. 
>
> > On Apr 29, 2015, at 7:55 AM, Anubhav Kaushik  > wrote: 
> > 
> >  but i am not running ny nginx server , m just running default wsgi 
> server with django ,and files are still served file ,can you explain how 
> that is happening? 
> > 
> > On Wednesday, April 29, 2015 at 5:10:56 PM UTC+5:30, François 
> Schiettecatte wrote: 
> > I found this page which was pretty clear I think: 
> > 
> > http://wiki.nginx.org/XSendfile 
> >   
> > Looks like an nginx directive to serve a file as the content of the 
> response. 
> > 
> > F. 
> > 
> > > On Apr 29, 2015, at 7:28 AM, Anubhav Kaushik  
> wrote: 
> > > 
> > > yes francois ,when i searched the term ,all i got was links related to 
> nginx. 
> > > 
> > > On Wednesday, April 29, 2015 at 4:55:58 PM UTC+5:30, François 
> Schiettecatte wrote: 
> > > Which part do you mean? The 'X-Accel-Redirect’ ? 
> > > 
> > > François 
> > > 
> > > > On Apr 29, 2015, at 6:08 AM, Anubhav Kaushik  
> wrote: 
> > > > 
> > > > response = HttpResponse() 
> > > > 
> > > > protected = settings.PROTECTED_AUDIO_ROOT + path 
> > > > 
> > > > logger.info('Protected path: %s', protected) 
> > > > 
> > > > response["X-Accel-Redirect"] = protected 
> > > > 
> > > > response["Content-Type"] = "audio/mpeg" 
> > > > 
> > > > 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...@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/f59471d6-1baa-4a36-9d3c-327684049d65%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...@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/b29c48fc-cb9d-49dd-869f-140afd5d1b6d%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...@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/e158ec09-020a-4b80-9913-c0e2c3eccc8a%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/d0fd944b-f5b5-4a91-b228-60612ea7b333%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


selectfilter2 javascript and django

2015-04-29 Thread Dimitris Kougioumtzis
i want to use the selectfilter  widget for a view , the user in my django 
application is only active not staff because i want to restrict access to 
django admin pages. But selectfilter widget dosen't  work



the error i get is  


SyntaxError: expected expression, got '<'



/admin/jsi18n/ (line 1)
4
ReferenceError: interpolate is not defined

quickElement('h2', selector_available, interpolate(gettext('Available %s'), 
[fie...





how to use selectfilter functionality to other views in django application 
other tha the admin 


thx a lot 

-- 
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/d55b5432-daac-44f5-bc33-f1c3da2c5764%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: selectfilter2 javascript and django

2015-04-29 Thread Dimitris Kougioumtzis

ok i found it 

in the urls.py i add  the 

 (r'^jsi18n/$', 'django.views.i18n.javascript_catalog'),


and in template 

 



Τη Τετάρτη, 29 Απριλίου 2015 - 4:12:56 μ.μ. UTC+3, ο χρήστης Dimitris 
Kougioumtzis έγραψε:
>
> i want to use the selectfilter  widget for a view , the user in my django 
> application is only active not staff because i want to restrict access to 
> django admin pages. But selectfilter widget dosen't  work
>
>
>
> the error i get is  
>
>
> SyntaxError: expected expression, got '<'
>
> 
>
> /admin/jsi18n/ (line 1)
> 4
> ReferenceError: interpolate is not defined
>
> quickElement('h2', selector_available, interpolate(gettext('Available %s'), 
> [fie...
>
>
>
>
>
> how to use selectfilter functionality to other views in django application 
> other tha the admin 
>
>
> thx a lot 
>

-- 
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/d7a6ac80-cc94-4c02-80b4-99217866ef01%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Require code explaination

2015-04-29 Thread François Schiettecatte
Well the response does not seem to contain the audio file, to the best of my 
knowledge Django does not implement X-Accel-Redirect, are you running all this 
on the same machine? Maybe your browser is getting the file ? Seems unlikely. 
Have you tried something like ‘curl’ to make the request in debug mode to see 
what is coming over the wire back from Django?

F.

> On Apr 29, 2015, at 8:28 AM, Anubhav Kaushik  wrote:
> 
> yes i am working on this code but  i havnt wrote this code otherwise i would 
> not have required the explaination i guess.
> 
> and for your second question , i am not sure coz  as you said it looked like 
> nginx directive , but i am running it on default wsgi server included in 
> django . so i am asking how wsgi server is serving what a nginx is supposed 
> to serve?
> 
> On Wednesday, April 29, 2015 at 5:35:26 PM UTC+5:30, François Schiettecatte 
> wrote:
> You need to be a little more specific about what the context is, and what you 
> are observing, rather than just plastering up some code. 
> 
> - Is this code in an app you are working with ? Did you write this code ? 
> 
> - Is the audio file being served by your application through the  default 
> wsgi server included in django? 
> 
> F. 
> 
> > On Apr 29, 2015, at 7:55 AM, Anubhav Kaushik  wrote: 
> > 
> >  but i am not running ny nginx server , m just running default wsgi server 
> > with django ,and files are still served file ,can you explain how that is 
> > happening? 
> > 
> > On Wednesday, April 29, 2015 at 5:10:56 PM UTC+5:30, François Schiettecatte 
> > wrote: 
> > I found this page which was pretty clear I think: 
> > 
> > http://wiki.nginx.org/XSendfile 
> >   
> > Looks like an nginx directive to serve a file as the content of the 
> > response. 
> > 
> > F. 
> > 
> > > On Apr 29, 2015, at 7:28 AM, Anubhav Kaushik  
> > > wrote: 
> > > 
> > > yes francois ,when i searched the term ,all i got was links related to 
> > > nginx. 
> > > 
> > > On Wednesday, April 29, 2015 at 4:55:58 PM UTC+5:30, François 
> > > Schiettecatte wrote: 
> > > Which part do you mean? The 'X-Accel-Redirect’ ? 
> > > 
> > > François 
> > > 
> > > > On Apr 29, 2015, at 6:08 AM, Anubhav Kaushik  
> > > > wrote: 
> > > > 
> > > > response = HttpResponse() 
> > > > 
> > > > protected = settings.PROTECTED_AUDIO_ROOT + path 
> > > > 
> > > > logger.info('Protected path: %s', protected) 
> > > > 
> > > > response["X-Accel-Redirect"] = protected 
> > > > 
> > > > response["Content-Type"] = "audio/mpeg" 
> > > > 
> > > > 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...@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/f59471d6-1baa-4a36-9d3c-327684049d65%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...@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/b29c48fc-cb9d-49dd-869f-140afd5d1b6d%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...@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/e158ec09-020a-4b80-9913-c0e2c3eccc8a%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/d0fd944b-f5b5-4a91-b228-60612

Re: clear database (drop all tables)

2015-04-29 Thread Bill Freeman
With suitable privileges, you can drop the database and recreate it.  In at
least some databases the user privilege grants are not lost with the
database and don't have to be recreated when the database is.

And, if you're using SQLite, just remove the file.

On Wed, Apr 29, 2015 at 6:10 AM, lars van Gemerden 
wrote:

> Hi all,
>
> Is there a simple programmatic way to drop all tables in the database
> (e.g. for testing purposes), also without input prompts?
>
> Cheers, Lars
>
> --
> 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/0ebbbdb5-f9ad-437b-baaa-9a39358704cd%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/CAB%2BAj0vtNMzONsamOT1tinWDQFCF3k9Q29yFitq7nowBUecdWA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django BooleanField Checkbox Returns Empty

2015-04-29 Thread Ken Nguyen
I read every corner of the documentation but couldn't figure out why the 
BooleanField Form doesn't return 'True' when the checkbox is checked. Is 
this a valid test? Shouldn't formset.cleaned_data = [{True}, {False}]?



>>> from django import forms
>>> from django.forms.formsets import formset_factory
>>>
>>> class CheckBox (forms.Form):
...overwrite = forms.BooleanField (required = False)
...
>>>
>>> data = {
... 'form-TOTAL_FORMS': '2',
... 'form-INITIAL_FORMS': '0',
... 'form-MAX_NUM_FORMS': '3',
... 'checkbox-0-overwrite': True,
... 'checkbox-1-overwrite': False,
...}
>>>
>>> CheckboxFormSet = formset_factory (CheckBox)
>>> formset = CheckboxFormSet (data)
>>> formset.is_valid ()
True
>>> formset.cleaned_data
[{}, {}]
>>>


-- 
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/2fe2c1e6-5644-464e-8e35-36d22e5257b1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: clear database (drop all tables)

2015-04-29 Thread Derek
As usual, StackOverflow to the rescue ...

http://stackoverflow.com/questions/3414247/django-drop-all-tables-from-database


On Wednesday, 29 April 2015 12:11:51 UTC+2, lars van Gemerden wrote:
>
> Hi all,
>
> Is there a simple programmatic way to drop all tables in the database 
> (e.g. for testing purposes), also without input prompts?
>
> Cheers, Lars
>

-- 
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/ae2099c6-9fea-46a9-928d-f5aa99cc7afb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django runserver needs restart on psql data changes

2015-04-29 Thread Arnab Banerji
Hi all - I am working on a Django app that interacts with a psql database 
via a set of models. 

(1) There is a backend job which keeps updating the database via the same 
models. 

(2) I am creating a table with a view using django_tables2 - and giving it 
a custom dictionary to render using data from the psql database (via my 
Django models). 

(3) I am using 'runserver' fpr testing out my code. 

The rendering happens perfectly, but the problem is - when the client user 
does a browser refresh, the new data does not get reloaded until I restart 
the runserver. Is there something I am doing wrong with respect to getting 
the data from the database and into my view?

Appreciate any help you might give me on this topic,
-AB

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/08207f93-9c4a-4c98-8fca-6499e6735125%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RemovedInDjango19Warning: Model class %s doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS ..

2015-04-29 Thread Bumyong Choi
I am trying to understand this warning better. I understand that we want to 
make sure that a model has an explicit app_label or it is in 
INSTALLED_APPS. I spent some time trying to remove warnings from my code 
because I was getting these warning messages even though my model was 
defined in an app listed in INSTALLED_APPS. 

After scratching my head for quite some time, I put a breakpoint on the 
following line of the code in django.db.models.base:



# Look for an application configuration to attach the model to.

app_config = apps.get_containing_app_config(module)

And I checked to see what I get for "app_configs.values()" and I realized 
that the app is in INSTALLED_APPS but not yet been loaded. This was because 
one of the third party framework I use was trying to import models before 
they were loaded. 

My question is the following:

Is Django trying to prevent a model from being imported before this model 
is actually defined? If this is the case, is it possible to improve the 
warning so that it would check "INSTALLED_APPS" and warn the user that even 
if the app is listed there some other app is trying to import the model 
before the app is loaded?"

If the intention is not as aforementioned, is this a bug?

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/ea782849-8c6a-48b1-92e2-1cdfabf15c4c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django runserver needs restart on psql data changes

2015-04-29 Thread Javier Guerra Giraldez
On Wed, Apr 29, 2015 at 12:35 PM, Arnab Banerji  wrote:
> The rendering happens perfectly, but the problem is - when the client user
> does a browser refresh, the new data does not get reloaded until I restart
> the runserver. Is there something I am doing wrong with respect to getting
> the data from the database and into my view?


sounds like you're storing that data in a variable.  you should either
read it from database on every request, or get some cache invalidation
techniques.

-- 
Javier

-- 
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/CAFkDaoTY%3Dfxx7RHRKjjJsHJaAvUJoDtL1fS1-dgM2MeifsaVjg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django runserver needs restart on psql data changes

2015-04-29 Thread Arnab Banerji
Hi Javier - thanks for the response. Yes - I am storing the data in a 
dictionary - then having django_tables2 API render the dictionary as a 
table. How do I force a read of that variable for every browser refresh on 
the client side? 

Thanks for your time,
-AB

On Wednesday, April 29, 2015 at 3:09:26 PM UTC-5, Javier Guerra wrote:
>
> On Wed, Apr 29, 2015 at 12:35 PM, Arnab Banerji  > wrote: 
> > The rendering happens perfectly, but the problem is - when the client 
> user 
> > does a browser refresh, the new data does not get reloaded until I 
> restart 
> > the runserver. Is there something I am doing wrong with respect to 
> getting 
> > the data from the database and into my view? 
>
>
> sounds like you're storing that data in a variable.  you should either 
> read it from database on every request, or get some cache invalidation 
> techniques. 
>
> -- 
> Javier 
>

-- 
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/3d2af574-e329-41ca-b2f2-1d1ba03f991e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django runserver needs restart on psql data changes

2015-04-29 Thread Carl Meyer
Hi Arnab,

On 04/29/2015 03:13 PM, Arnab Banerji wrote:
> Hi Javier - thanks for the response. Yes - I am storing the data in a
> dictionary - then having django_tables2 API render the dictionary as a
> table. How do I force a read of that variable for every browser refresh
> on the client side? 

Using a variable is fine; the problem is that (I'm guessing) you are
creating that variable at the top level of the module. Such code is only
run once, when the module is first imported.

You need to make sure that all database queries are run only inside view
functions (or methods of view classes), never at the top-level of a module.

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/5541568D.1060808%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


Re: RemovedInDjango19Warning: Model class %s doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS ..

2015-04-29 Thread Carl Meyer
Hi,

On 04/29/2015 11:13 AM, Bumyong Choi wrote:
> I am trying to understand this warning better. I understand that we want
> to make sure that a model has an explicit app_label or it is in
> INSTALLED_APPS. I spent some time trying to remove warnings from my code
> because I was getting these warning messages even though my model was
> defined in an app listed in INSTALLED_APPS. 
> 
> After scratching my head for quite some time, I put a breakpoint on the
> following line of the code in django.db.models.base:
> 
> # Look for an application configuration to attach the model to.
> 
> app_config =apps.get_containing_app_config(module)
> 
> And I checked to see what I get for "app_configs.values()" and I
> realized that the app is in INSTALLED_APPS but not yet been loaded. This
> was because one of the third party framework I use was trying to import
> models before they were loaded. 
> 
> My question is the following:
> 
> Is Django trying to prevent a model from being imported before this
> model is actually defined? If this is the case, is it possible to
> improve the warning so that it would check "INSTALLED_APPS" and warn the
> user that even if the app is listed there some other app is trying to
> import the model before the app is loaded?"

Yes, that is the current intention in Django 1.7+: you may not import a
models.py file before the app cache has been prepared. (I personally
think this is unfortunate, but to change it while maintaining consistent
and predictable semantics would require a deep reworking of how relation
fields are initialized, which nobody has so far attempted).

I'm surprised you are getting that particular error though - if a
models.py file is imported too soon, I would expect an "App registry not
ready" error instead. So it may be a bug that you are getting this error
message instead of that one; hard to know without seeing code to
reproduce the issue.

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/554157B1.5000702%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


upload csv file from different directories

2015-04-29 Thread sum abiut
Hi I am writing an app that upload csv file and write csv data to models.
So far everything is working fine. What i want to do now is to be able get
the users to be able to upload csv files from different directories.  I
cannot seem to figure this out, i need directions. form the  function*
csvimport* is there are a way to get the user select the file from
different directories, instead of hard coding the path (with
open('/var/www/html/webapp/csvupload/data1.csv')

here is my codes.

view.py

def showuploadform(request):
if request.method=='POST':
form = uploadform(request.POST, request.FILES)
if form.is_valid():
csvimport(request.FILES['Select_CSV_Files'])
return render_to_response('csv_test.html',locals())
else:
form = uploadform()
return render(request,'uploadform.html',{'form': form})



def csvimport(request):
with open('/var/www/html/webapp/csvupload/data1.csv','rb') as csvfile:
readata=csv.reader(csvfile,delimiter=',', quotechar='"')
for row in readata:
if row[0] != 'PersonID':
data=csvfiles()
data.PersonID=row[0]
data.Firstname=row[1]
data.Lastname=row[2]
data.Address=row[3]
data.save()
return render_to_response('csv_test.html',locals())

forms.py

class uploadform(forms.Form):
Select_CSV_Files=forms.FileField()

uploadform.html



{%csrf_token%}

{{form.as_table}}







{%endblock%}

-- 
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/CAPCf-y4Zofe-Q1YsQRqMY2qUj0bBfSTpbzOJqs%2Btyn7z4Y5XDQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django runserver needs restart on psql data changes

2015-04-29 Thread Arnab Banerji
Hi Carl - that was *exactly* what I was doing - thanks a ton for finding 
that issue even without requiring the code. Now that I think about it, 
putting that definition in the global section makes absolutely no sense.

Appreciate your feedback,
-AB

On Wednesday, April 29, 2015 at 5:10:21 PM UTC-5, Carl Meyer wrote:
>
> Hi Arnab, 
>
> On 04/29/2015 03:13 PM, Arnab Banerji wrote: 
> > Hi Javier - thanks for the response. Yes - I am storing the data in a 
> > dictionary - then having django_tables2 API render the dictionary as a 
> > table. How do I force a read of that variable for every browser refresh 
> > on the client side? 
>
> Using a variable is fine; the problem is that (I'm guessing) you are 
> creating that variable at the top level of the module. Such code is only 
> run once, when the module is first imported. 
>
> You need to make sure that all database queries are run only inside view 
> functions (or methods of view classes), never at the top-level of a 
> module. 
>
> 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/346855d5-2e89-4ccd-a2e7-0531a9573971%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.