NAS using Django

2016-03-09 Thread Vayuj Rajan
Hi,
I have a query whether we can implement NAS (network attached storage) 
functionality using Django framework?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9a9914d7-37cf-4608-892a-2f0a08b001a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Migrations bork: relation "django_site" does not exist

2016-03-09 Thread Malte
Hi all,

I ran into this error trying to migrate my apps with a blank Postgres 
database.

django.db.utils.ProgrammingError: relation "django_site" does not exist

LINE 1: ..."django_site"."domain", "django_site"."name" FROM "django_si...

The issue was raised by others (e.g. on SOF 
http://stackoverflow.com/questions/23925726/django-relation-django-site-does-not-exist)
 
but not really solved.

I realised that I could work around this issue by 
Step 1: commenting out all of the apps that I custom built from (A) 
INSTALLED_APPS and (B) urls.py
Step 2: running .manage.py migrate
Step 3: commenting my apps back in
Step 4: running .manage.py migrate

But this doesn't seem right. None of the suggestions out there have worked 
for me, including: ./manage.py migrate sites (which results in the same 
error).
In fact, whatever migrate or makemigrations command I run, it all results 
in the "relation "django_site" does not exist" error.

So I came across this, where the last comms dates back less than 2 weeks 
with Simon Charette taking it to the irc channel.

https://code.djangoproject.com/ticket/24524

Is there any follow-up from this?

Thanks!
/Malte

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6eb6928f-8b72-45bd-b856-aff19edbb0d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


addField ForeignKey during migrations create unusable constraint name

2016-03-09 Thread Gromish


Env: Django 1.8.11 + Postgis

I'm adding some ForeignKeys on a MyModel. The models pointed are in another 
schema ("cartography").

makemigrations

no errors

migrate

One error. Can't create the constraint because the generated name. But I'm 
adding 10 fields, really similar between them. Only one is giving that 
stupid error. I can't specify the constraint name anywhere.

class myModel(models.Model)
zps_calculated = models.ForeignKey( Cartography_zps, 
verbose_name="zps_calcolato", null=True, blank=True, on_delete=models.SET_NULL)
zsc_sic_sir_calculated = models.ForeignKey( Cartography_zsc_sic_sir, 
verbose_name="zsc_sic_sir_calcolato", null=True, blank=True, 
on_delete=models.SET_NULL)
manyothersdata = "xxx"

That is the slice of code generated from sqlmigrate (to inspect the code 
the migration generate). As you see the name of the constraint is the 
error. 1 on 10 fields is giving the error

CREATE INDEX "segnalazioni_f38ba181" ON "segnalazioni" 
("zps_calculated_id");ALTER TABLE "segnalazioni" ADD CONSTRAINT 
"se_zps_calculated_id_6844dce0603174b2_fk_"cartography"."zps"_id" FOREIGN KEY 
("zps_calculated_id") REFERENCES "cartography"."zps" ("id") DEFERRABLE 
INITIALLY DEFERRED;CREATE INDEX "segnalazioni_eb52e53f" ON "segnalazioni" 
("zsc_sic_sir_calculated_id");ALTER TABLE "segnalazioni" ADD CONSTRAINT 
"cc6ce48808e3a5292779a9787d21e5ad" FOREIGN KEY ("zsc_sic_sir_calculated_id") 
REFERENCES "cartography"."zsc_sic_sir" ("id") DEFERRABLE INITIALLY DEFERRED;

That is the name giving the error: 
"se_zps_calculated_id_6844dce0603174b2_fk_"cartography"."zps"_id" I think 
should be something like: "6844dce0603174b2..."

the model NOT giving the error:

class Cartography_zsc_sic_sir(models.Model):
id = models.AutoField(primary_key=True)
slug = models.CharField(max_length=40, blank=True, null=True)
nome = models.CharField(max_length=60, blank=True, null=True)
the_geom = models.MultiPolygonField(srid=23032, blank=True, null=True )
objects = models.GeoManager()

class Meta:
managed = False
db_table = '"cartography"."zsc_sic_sir"'
verbose_name = 'Cartography - zsc_sic_sir'
verbose_name_plural = 'Cartography - zsc_sic_sir'
ordering = ["id","slug"]

def __unicode__(self):
return self.nome

that is the model giving the error:

class Cartography_zps(models.Model):
id = models.AutoField(primary_key=True)
slug = models.CharField(max_length=40, blank=True, null=True)
the_geom = models.MultiPolygonField(srid=23032, blank=True, null=True )
objects = models.GeoManager()

class Meta:
managed = False
db_table = '"cartography"."zps"'
verbose_name = 'Cartography - ZPS'
verbose_name_plural = 'Cartography - ZPS'
ordering = ["id","slug"]

def __unicode__(self):
return self.slug

Going further I'm investigating in Django code, backwards.

The

 ' %s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)%s;' %

is in /django/db/backends/base/creation.py row 180

using that

qn = self.connection.ops.quote_name

that SHOULD be the %s constraint name value:

qn(truncate_name(r_name, self.connection.ops.max_name_length()))

Anyone have an hint to help me? I'm gonna look what qn does.




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/82a799ff-78bf-4e75-994a-4d7a1c58dcda%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python on the web

2016-03-09 Thread Vikramjeet Raj
Yes, Please let me know what you need to get done.

On Monday, 7 March 2016 21:21:53 UTC+5:30, Gregg Turner wrote:
>
> Hey,
>
> Need a simple python script put into a website. It uses the requests 
> module.
>
> $20? Any takers? 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cfab294b-319f-4ae9-b845-596fa4bc3680%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NAS using Django

2016-03-09 Thread Andreas Kuhne
Hi Vayuj,

I think you have to be a bit more specific. Django is a web framework, used
for creating web applications and websites. A NAS is usually an array of
harddrives that has different file sharing protocols attached (for example
SMB or NFS).

It would be possible to implement something like Amazons S3 in django
however if that is what you want?

Regards,

Andréas

2016-03-09 12:09 GMT+01:00 Vayuj Rajan :

> Hi,
> I have a query whether we can implement NAS (network attached storage)
> functionality using Django framework?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9a9914d7-37cf-4608-892a-2f0a08b001a1%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALXYUbn0RpLCcEZDMnCj6-qvXKG3576w%2B9EdxeN_QUR1-Jg7Cw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Migrations bork: relation "django_site" does not exist

2016-03-09 Thread Michal Petrucha
On Tue, Mar 08, 2016 at 08:08:06PM -0800, Malte wrote:
> Hi all,
> 
> I ran into this error trying to migrate my apps with a blank Postgres 
> database.
> 
> django.db.utils.ProgrammingError: relation "django_site" does not exist
> 
> LINE 1: ..."django_site"."domain", "django_site"."name" FROM "django_si...
> 
> The issue was raised by others (e.g. on SOF 
> http://stackoverflow.com/questions/23925726/django-relation-django-site-does-not-exist)
>  
> but not really solved.
> 
> I realised that I could work around this issue by 
> Step 1: commenting out all of the apps that I custom built from (A) 
> INSTALLED_APPS and (B) urls.py
> Step 2: running .manage.py migrate
> Step 3: commenting my apps back in
> Step 4: running .manage.py migrate
> 
> But this doesn't seem right. None of the suggestions out there have worked 
> for me, including: ./manage.py migrate sites (which results in the same 
> error).
> In fact, whatever migrate or makemigrations command I run, it all results 
> in the "relation "django_site" does not exist" error.
> 
> So I came across this, where the last comms dates back less than 2 weeks 
> with Simon Charette taking it to the irc channel.
> 
> https://code.djangoproject.com/ticket/24524
> 
> Is there any follow-up from this?

The symptoms described in the ticket do not match yours.

You wrote that you're getting the error even when running
makemigrations, whereas the reporter of that ticket wrote that
makemigrations succeeds, but a subsequent migrate fails.

>From what you described, it seems like your project tries to perform a
database query on startup, which obviously will not work before you
actually create the database with an up-to-date schema. It's
impossible to tell with certainty without seeing the full traceback or
any code, but it looks like you are trying to fetch a Site object from
the database on startup (as in, one of your applications makes queries
on import time). This is simply not supported, because such an
operation does not make sense, when you think about it. (There's a
chicken-and-egg problem in this scenario.)

All in all, from your description is seems to me that there is nothing
Django can do about the issue, but you'll have to provide more
information in order for us to help you resolve the problem.

Cheers,

Michal

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20160309124156.GI25061%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: NAS using Django

2016-03-09 Thread Vayuj Rajan
What I wanted to do is to connect the file sharing protocols to this web 
application i.e the one I will be making it from Django and I wanted to 
host this application using apache so that it can be hosted locally.

On Wednesday, March 9, 2016 at 6:05:51 PM UTC+5:30, Andréas Kühne wrote:
>
> Hi Vayuj,
>
> I think you have to be a bit more specific. Django is a web framework, 
> used for creating web applications and websites. A NAS is usually an array 
> of harddrives that has different file sharing protocols attached (for 
> example SMB or NFS).
>
> It would be possible to implement something like Amazons S3 in django 
> however if that is what you want?
>
> Regards,
>
> Andréas
>
> 2016-03-09 12:09 GMT+01:00 Vayuj Rajan >:
>
>> Hi,
>> I have a query whether we can implement NAS (network attached storage) 
>> functionality using Django framework?
>>
>> -- 
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/9a9914d7-37cf-4608-892a-2f0a08b001a1%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fe72a195-2815-42ef-867c-6245d9e62d1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problems with same page scroll plugin in django-cms

2016-03-09 Thread dev . fekioh
Hi all, 

I have a problem using the  cmsplugin-sections 
 plugin for same page 
navigation

I am trying to use it and  I run into a *'NoneType' object is not iterable 
error* when trying to add a section container. Full information here 

 
(asked on stackoverflow but no answer...) 

Any tips welcome.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2bc96ff3-6ab1-4cc8-ba83-08c8f25549a7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


execute python through ajax

2016-03-09 Thread Florian Hoedt
Hello Django users,
I would like to execute some python code by JS. For example if somebody 
clicks on a openlayers map it should execute a python based query and get 
the result as JSON to render it on the map.
How would I achieve something like this?

I am trying to understand the forms section of the official django tutorial 
without success.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a293a0a0-32a0-4333-aefd-d5c15e810a60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: execute code at startup

2016-03-09 Thread Vernon D. Cole
I think if I were doing this, I would write a custom management command 
 
to update the tables, and run it at system startup time. Management 
commands are easy to debug and well documented.

On Tuesday, March 8, 2016 at 10:38:25 AM UTC-7, Julien Greard wrote:
>
> Hello,
>
> I am using Django 1.9.3. I have a project with several apps. I would like 
> to update the tables of one of the app at the startup of the project.
>
> I have all the code written, it looks like the following (it's an example):
>
> from my_app.models import My_table
>
> def on_startup():
>  my_thread = Thread(execute = populate_tables, loopmode = True, 
> background = True) *# thread running in loopmode in background*
>  my_thread.start() *# starts the thread and returns*
>
> def populate_tables()
>  response = call_webservice() *# let's imagine this method returns 
> data for creating a new model instance*
>  My_table(response).save() # this save() isn't threadsafe in this 
> example, but that's not my point ;-)
>
> So far, with Django 1.6.5, I came with some code from the __init__.py file 
> of my app. It was working, but I thought it was quite ugly (starting a 
> thread with an "import" looks really like hidden code).
>
> I saw in Django 1.9 the "ready()" method. But it's written in the 
> documentation to not deal with models in this method so I am confused.
>
> I could add the startup code in the command starting my server but this 
> startup code is app oriented and in my opinion, the projects has nothing to 
> do with my app.
>
> What do you recommend?
>
>
> I'd be happy to provide more info if needed.
>
> Thanks in advance,
>
> Julien Gréard
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/49d4a061-973e-4e54-b99a-383fdbcb2822%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: execute python through ajax

2016-03-09 Thread Bob Gailer
On Mar 9, 2016 9:22 AM, "Florian Hoedt"  wrote:
>
> Hello Django users,
> I would like to execute some python code by JS. For example if somebody
clicks on a openlayers map it should execute a python based query and get
the result as JSON to render it on the map.
> How would I achieve something like this?
Google Django Ajax. There's a number of good references there.
>
> I am trying to understand the forms section of the official django
tutorial without success.
This sounds like a separate issue. What's your objective and where are you
stuck?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP1rxO6pLs13%3DZ3jRBAOkO0YUoCM2cQJ81mmsWGRDgu5U1pJmw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NAS using Django

2016-03-09 Thread Aaron C. de Bruyn
That's still pretty vague.  What 'file sharing protocols' are you talking
about specifically?  And what do you mean by wanting to 'connect' the file
sharing protocols to the application?

There is a PySMB library that will allow your Django application to pretend
to be a Windows client.

If you're just talking about having the Django application display existing
files/mounts, there are various built-in tools for that.

You might want to take a look at the FreeNAS project.  They have a Django
application running as a front-end to their FreeNAS appliance.

-A

On Wed, Mar 9, 2016 at 4:50 AM, Vayuj Rajan  wrote:

> What I wanted to do is to connect the file sharing protocols to this web
> application i.e the one I will be making it from Django and I wanted to
> host this application using apache so that it can be hosted locally.
>
> On Wednesday, March 9, 2016 at 6:05:51 PM UTC+5:30, Andréas Kühne wrote:
>>
>> Hi Vayuj,
>>
>> I think you have to be a bit more specific. Django is a web framework,
>> used for creating web applications and websites. A NAS is usually an array
>> of harddrives that has different file sharing protocols attached (for
>> example SMB or NFS).
>>
>> It would be possible to implement something like Amazons S3 in django
>> however if that is what you want?
>>
>> Regards,
>>
>> Andréas
>>
>> 2016-03-09 12:09 GMT+01:00 Vayuj Rajan :
>>
>>> Hi,
>>> I have a query whether we can implement NAS (network attached storage)
>>> functionality using Django framework?
>>>
>>> --
>>> 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 https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/9a9914d7-37cf-4608-892a-2f0a08b001a1%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fe72a195-2815-42ef-867c-6245d9e62d1c%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEE%2BrGpsfTR_SH2jJk%2B3F3PxNLAmvgQYsd%3D9a4FHFSpJu3xvbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: addField ForeignKey during migrations create unusable constraint name

2016-03-09 Thread Simon Charette
Hi Gromish,

>From looking at you models `db_table` options it looks like you are using a
work around to use a table defined in a non default schema (cartography).

Django doesn't officially support custom schema yet[1] but there's an 
ongoing
effort to get basic support merged in Django 1.10[2] that you could review.

In the meantime I suggest you replace your migration's `AddField` of
`ForeignKey` by `SeparateDatabaseAndState`:

Replace

AddField(
model_name='myModel',
name='zps_calculated',
field=models.ForeignKey(to='app.Cartography_zps'),
)

By

AddField(
model_name='myModel',
name='zps_calculated_id',
field=models.IntegerField(db_index=True),
)
SeparateDatabaseAndState(
[RunSQL("""
ALTER TABLE "segnalazioni" ADD CONSTRAINT
"se_zps_calculated_id_6844dce0603174b2_fk_cartography_zps_id"
FOREIGN KEY ("zps_calculated_id")
REFERENCES "cartography"."zps" ("id") DEFERRABLE INITIALLY DEFERRED;
""")],
[AlterField(
model_name='myModel',
name='zps_calculated_id',
field=models.ForeignKey(to='app.Cartography_zps', 
name='zps_calculated')
)],
)

Cheers,
Simon

[1] https://code.djangoproject.com/ticket/6148
[2] https://github.com/django/django/pull/6162

Le mercredi 9 mars 2016 07:15:17 UTC-5, Gromish a écrit :
>
> Env: Django 1.8.11 + Postgis
>
> I'm adding some ForeignKeys on a MyModel. The models pointed are in 
> another schema ("cartography").
>
> makemigrations
>
> no errors
>
> migrate
>
> One error. Can't create the constraint because the generated name. But I'm 
> adding 10 fields, really similar between them. Only one is giving that 
> stupid error. I can't specify the constraint name anywhere.
>
> class myModel(models.Model)
> zps_calculated = models.ForeignKey( Cartography_zps, 
> verbose_name="zps_calcolato", null=True, blank=True, 
> on_delete=models.SET_NULL)
> zsc_sic_sir_calculated = models.ForeignKey( Cartography_zsc_sic_sir, 
> verbose_name="zsc_sic_sir_calcolato", null=True, blank=True, 
> on_delete=models.SET_NULL)
> manyothersdata = "xxx"
>
> That is the slice of code generated from sqlmigrate (to inspect the code 
> the migration generate). As you see the name of the constraint is the 
> error. 1 on 10 fields is giving the error
>
> CREATE INDEX "segnalazioni_f38ba181" ON "segnalazioni" 
> ("zps_calculated_id");ALTER TABLE "segnalazioni" ADD CONSTRAINT 
> "se_zps_calculated_id_6844dce0603174b2_fk_"cartography"."zps"_id" FOREIGN KEY 
> ("zps_calculated_id") REFERENCES "cartography"."zps" ("id") DEFERRABLE 
> INITIALLY DEFERRED;CREATE INDEX "segnalazioni_eb52e53f" ON "segnalazioni" 
> ("zsc_sic_sir_calculated_id");ALTER TABLE "segnalazioni" ADD CONSTRAINT 
> "cc6ce48808e3a5292779a9787d21e5ad" FOREIGN KEY ("zsc_sic_sir_calculated_id") 
> REFERENCES "cartography"."zsc_sic_sir" ("id") DEFERRABLE INITIALLY DEFERRED;
>
> That is the name giving the error: 
> "se_zps_calculated_id_6844dce0603174b2_fk_"cartography"."zps"_id" I think 
> should be something like: "6844dce0603174b2..."
>
> the model NOT giving the error:
>
> class Cartography_zsc_sic_sir(models.Model):
> id = models.AutoField(primary_key=True)
> slug = models.CharField(max_length=40, blank=True, null=True)
> nome = models.CharField(max_length=60, blank=True, null=True)
> the_geom = models.MultiPolygonField(srid=23032, blank=True, null=True )
> objects = models.GeoManager()
>
> class Meta:
> managed = False
> db_table = '"cartography"."zsc_sic_sir"'
> verbose_name = 'Cartography - zsc_sic_sir'
> verbose_name_plural = 'Cartography - zsc_sic_sir'
> ordering = ["id","slug"]
>
> def __unicode__(self):
> return self.nome
>
> that is the model giving the error:
>
> class Cartography_zps(models.Model):
> id = models.AutoField(primary_key=True)
> slug = models.CharField(max_length=40, blank=True, null=True)
> the_geom = models.MultiPolygonField(srid=23032, blank=True, null=True )
> objects = models.GeoManager()
>
> class Meta:
> managed = False
> db_table = '"cartography"."zps"'
> verbose_name = 'Cartography - ZPS'
> verbose_name_plural = 'Cartography - ZPS'
> ordering = ["id","slug"]
>
> def __unicode__(self):
> return self.slug
>
> Going further I'm investigating in Django code, backwards.
>
> The
>
>  ' %s ADD CONSTRAINT %s FOREIGN KEY (%s) REFERENCES %s (%s)%s;' %
>
> is in /django/db/backends/base/creation.py row 180
>
> using that
>
> qn = self.connection.ops.quote_name
>
> that SHOULD be the %s constraint name value:
>
> qn(truncate_name(r_name, self.connection.ops.max_name_length()))
>
> Anyone have an hint to help me? I'm gonna look what qn does.
>
>
>
>
>

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

Re: Python on the web

2016-03-09 Thread Mario R. Osorio
There you are: http://hlevkin.com/Shell_progr/hellopython.htm

Please send the $20 to my paypal account...

On Monday, March 7, 2016 at 10:51:53 AM UTC-5, Gregg Turner wrote:
>
> Hey,
>
> Need a simple python script put into a website. It uses the requests 
> module.
>
> $20? Any takers? 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0ec5e37b-60a8-406b-bd5e-91f6040621dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Problem with create new instance

2016-03-09 Thread Dariusz Mysior
I have Django 1.8 Python 3.4 

My app contact. I have model and form like below and when I run command 

 

> from contact.forms import MessageForm
>
 and next 

> form = MessageForm()
>

I have error

In[2]: from contact.forms import MessageForm
>> In[3]: form = MessageForm()
>> Traceback (most recent call last):
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>  
>> line 161, in _add_installed_apps_translations
>> app_configs = reversed(list(apps.get_app_configs()))
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/apps/registry.py",
>>  
>> line 137, in get_app_configs
>> self.check_apps_ready()
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/apps/registry.py",
>>  
>> line 124, in check_apps_ready
>> raise AppRegistryNotReady("Apps aren't loaded yet.")
>> django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
>>
>> During handling of the above exception, another exception occurred:
>>
>> Traceback (most recent call last):
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/IPython/core/interactiveshell.py",
>>  
>> line 3066, in run_code
>> exec(code_obj, self.user_global_ns, self.user_ns)
>>   File "", line 1, in 
>> form = MessageForm()
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/forms/models.py",
>>  
>> line 329, in __init__
>> error_class, label_suffix, empty_permitted)
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/forms/forms.py",
>>  
>> line 129, in __init__
>> self.label_suffix = label_suffix if label_suffix is not None else 
>> _(':')
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/__init__.py",
>>  
>> line 84, in ugettext
>> return _trans.ugettext(message)
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>  
>> line 317, in gettext
>> return do_translate(message, 'gettext')
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>  
>> line 300, in do_translate
>> _default = _default or translation(settings.LANGUAGE_CODE)
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>  
>> line 206, in translation
>> _translations[language] = DjangoTranslation(language)
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>  
>> line 116, in __init__
>> self._add_installed_apps_translations()
>>   File 
>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>  
>> line 164, in _add_installed_apps_translations
>> "The translation infrastructure cannot be initialized before the "
>> django.core.exceptions.AppRegistryNotReady: The translation 
>> infrastructure cannot be initialized before the apps registry is ready. 
>> Check that you don't make non-lazy gettext calls at import time.
>
>
models.py
 

from django.db import models

# Create your models here.

class Message(models.Model):
name = models.CharField(max_length=250)
email = models.EmailField()
message = models.TextField()

def __str__(self):
return "message from {name}".format(name=self.name)




forms.py

#!/usr/bin/env python
from django import forms
from .models import Message

class MessageForm(forms.ModelForm):
class Meta:
model = Message
fields = ['name', 'email', 'message']




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/38123445-2b27-489b-8029-fa591aa5091b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with create new instance

2016-03-09 Thread Dariusz Mysior
I found that when I write import django and next django.setup() to terminal 
than it works. But next question, when I put it to automaticly run it...

W dniu środa, 9 marca 2016 18:48:15 UTC+1 użytkownik Dariusz Mysior napisał:
>
> I have Django 1.8 Python 3.4 
>
> My app contact. I have model and form like below and when I run command 
>
>  
>
>> from contact.forms import MessageForm
>>
>  and next 
>
>> form = MessageForm()
>>
>
> I have error
>
> In[2]: from contact.forms import MessageForm
>>> In[3]: form = MessageForm()
>>> Traceback (most recent call last):
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 161, in _add_installed_apps_translations
>>> app_configs = reversed(list(apps.get_app_configs()))
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/apps/registry.py",
>>>  
>>> line 137, in get_app_configs
>>> self.check_apps_ready()
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/apps/registry.py",
>>>  
>>> line 124, in check_apps_ready
>>> raise AppRegistryNotReady("Apps aren't loaded yet.")
>>> django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
>>>
>>> During handling of the above exception, another exception occurred:
>>>
>>> Traceback (most recent call last):
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/IPython/core/interactiveshell.py",
>>>  
>>> line 3066, in run_code
>>> exec(code_obj, self.user_global_ns, self.user_ns)
>>>   File "", line 1, in 
>>> form = MessageForm()
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/forms/models.py",
>>>  
>>> line 329, in __init__
>>> error_class, label_suffix, empty_permitted)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/forms/forms.py",
>>>  
>>> line 129, in __init__
>>> self.label_suffix = label_suffix if label_suffix is not None else 
>>> _(':')
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/__init__.py",
>>>  
>>> line 84, in ugettext
>>> return _trans.ugettext(message)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 317, in gettext
>>> return do_translate(message, 'gettext')
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 300, in do_translate
>>> _default = _default or translation(settings.LANGUAGE_CODE)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 206, in translation
>>> _translations[language] = DjangoTranslation(language)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 116, in __init__
>>> self._add_installed_apps_translations()
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 164, in _add_installed_apps_translations
>>> "The translation infrastructure cannot be initialized before the "
>>> django.core.exceptions.AppRegistryNotReady: The translation 
>>> infrastructure cannot be initialized before the apps registry is ready. 
>>> Check that you don't make non-lazy gettext calls at import time.
>>
>>
> models.py
>  
>
> from django.db import models
>
> # Create your models here.
>
> class Message(models.Model):
> name = models.CharField(max_length=250)
> email = models.EmailField()
> message = models.TextField()
>
> def __str__(self):
> return "message from {name}".format(name=self.name)
>
>
>
>
> forms.py
>
> #!/usr/bin/env python
> from django import forms
> from .models import Message
>
> class MessageForm(forms.ModelForm):
> class Meta:
> model = Message
> fields = ['name', 'email', 'message']
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1d4fef2a-c2f0-4a96-ade3-0185013304af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with create new instance

2016-03-09 Thread Dariusz Mysior
Ok I have it. I put it to starting scripts

W dniu środa, 9 marca 2016 18:48:15 UTC+1 użytkownik Dariusz Mysior napisał:
>
> I have Django 1.8 Python 3.4 
>
> My app contact. I have model and form like below and when I run command 
>
>  
>
>> from contact.forms import MessageForm
>>
>  and next 
>
>> form = MessageForm()
>>
>
> I have error
>
> In[2]: from contact.forms import MessageForm
>>> In[3]: form = MessageForm()
>>> Traceback (most recent call last):
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 161, in _add_installed_apps_translations
>>> app_configs = reversed(list(apps.get_app_configs()))
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/apps/registry.py",
>>>  
>>> line 137, in get_app_configs
>>> self.check_apps_ready()
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/apps/registry.py",
>>>  
>>> line 124, in check_apps_ready
>>> raise AppRegistryNotReady("Apps aren't loaded yet.")
>>> django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
>>>
>>> During handling of the above exception, another exception occurred:
>>>
>>> Traceback (most recent call last):
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/IPython/core/interactiveshell.py",
>>>  
>>> line 3066, in run_code
>>> exec(code_obj, self.user_global_ns, self.user_ns)
>>>   File "", line 1, in 
>>> form = MessageForm()
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/forms/models.py",
>>>  
>>> line 329, in __init__
>>> error_class, label_suffix, empty_permitted)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/forms/forms.py",
>>>  
>>> line 129, in __init__
>>> self.label_suffix = label_suffix if label_suffix is not None else 
>>> _(':')
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/__init__.py",
>>>  
>>> line 84, in ugettext
>>> return _trans.ugettext(message)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 317, in gettext
>>> return do_translate(message, 'gettext')
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 300, in do_translate
>>> _default = _default or translation(settings.LANGUAGE_CODE)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 206, in translation
>>> _translations[language] = DjangoTranslation(language)
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 116, in __init__
>>> self._add_installed_apps_translations()
>>>   File 
>>> "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
>>>  
>>> line 164, in _add_installed_apps_translations
>>> "The translation infrastructure cannot be initialized before the "
>>> django.core.exceptions.AppRegistryNotReady: The translation 
>>> infrastructure cannot be initialized before the apps registry is ready. 
>>> Check that you don't make non-lazy gettext calls at import time.
>>
>>
> models.py
>  
>
> from django.db import models
>
> # Create your models here.
>
> class Message(models.Model):
> name = models.CharField(max_length=250)
> email = models.EmailField()
> message = models.TextField()
>
> def __str__(self):
> return "message from {name}".format(name=self.name)
>
>
>
>
> forms.py
>
> #!/usr/bin/env python
> from django import forms
> from .models import Message
>
> class MessageForm(forms.ModelForm):
> class Meta:
> model = Message
> fields = ['name', 'email', 'message']
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/06587c6f-b752-48d5-a29b-4c9914d1a484%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem with create new instance

2016-03-09 Thread knbk
Any reason you're not using `manage.py shell`? It automatically loads the 
Django environment, and supports IPython. 

On Wednesday, March 9, 2016 at 7:35:45 PM UTC+1, Dariusz Mysior wrote:
>
> Ok I have it. I put it to starting scripts
>
> W dniu środa, 9 marca 2016 18:48:15 UTC+1 użytkownik Dariusz Mysior 
> napisał:
>>
>> I have Django 1.8 Python 3.4 
>>
>> My app contact. I have model and form like below and when I run command 
>>
>>  
>>
>>> from contact.forms import MessageForm
>>>
>>  and next 
>>
>>> form = MessageForm()
>>>
>>
>> I have error
>>
>> In[2]: from contact.forms import MessageForm
 In[3]: form = MessageForm()
 Traceback (most recent call last):
   File 
 "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
  
 line 161, in _add_installed_apps_translations
 app_configs = reversed(list(apps.get_app_configs()))
   File 
 "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/apps/registry.py",
  
 line 137, in get_app_configs
 self.check_apps_ready()
   File 
 "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/apps/registry.py",
  
 line 124, in check_apps_ready
 raise AppRegistryNotReady("Apps aren't loaded yet.")
 django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File 
 "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/IPython/core/interactiveshell.py",
  
 line 3066, in run_code
 exec(code_obj, self.user_global_ns, self.user_ns)
   File "", line 1, in 
 form = MessageForm()
   File 
 "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/forms/models.py",
  
 line 329, in __init__
 error_class, label_suffix, empty_permitted)
   File 
 "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/forms/forms.py",
  
 line 129, in __init__
 self.label_suffix = label_suffix if label_suffix is not None else 
 _(':')
   File 
 "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/__init__.py",
  
 line 84, in ugettext
 return _trans.ugettext(message)
   File 
 "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
  
 line 317, in gettext
 return do_translate(message, 'gettext')
   File 
 "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
  
 line 300, in do_translate
 _default = _default or translation(settings.LANGUAGE_CODE)
   File 
 "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
  
 line 206, in translation
 _translations[language] = DjangoTranslation(language)
   File 
 "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
  
 line 116, in __init__
 self._add_installed_apps_translations()
   File 
 "/home/darek/.virtualenvs/kurs/lib/python3.4/site-packages/django/utils/translation/trans_real.py",
  
 line 164, in _add_installed_apps_translations
 "The translation infrastructure cannot be initialized before the "
 django.core.exceptions.AppRegistryNotReady: The translation 
 infrastructure cannot be initialized before the apps registry is ready. 
 Check that you don't make non-lazy gettext calls at import time.
>>>
>>>
>> models.py
>>  
>>
>> from django.db import models
>>
>> # Create your models here.
>>
>> class Message(models.Model):
>> name = models.CharField(max_length=250)
>> email = models.EmailField()
>> message = models.TextField()
>>
>> def __str__(self):
>> return "message from {name}".format(name=self.name)
>>
>>
>>
>>
>> forms.py
>>
>> #!/usr/bin/env python
>> from django import forms
>> from .models import Message
>>
>> class MessageForm(forms.ModelForm):
>> class Meta:
>> model = Message
>> fields = ['name', 'email', 'message']
>>
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d1d1bb08-8e5c-4f74-afb2-5266fc32ab42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django button function vs aesthetic

2016-03-09 Thread clarksonchris81


The following is derived from an old post but I can not seem to get the 
button to render in the way that I want it to.

Any help?

I am trying implement bootstrap on an upload button that is on the webpage.

class DocumentForm(forms.Form):
docfile = forms.FileField(label='Select file')
helper = FormHelper()
helper.form_class = 'form-horizontal'
helper.layout = Layout(
Div(
HTML('{{ form.docfile.label_tag }} {{ form.docfile.help_text 
}}'),
css_class='col-sm-4 col-md-9 col-lg-9',
 ),
   )

I have definitely downloaded crispy forms and installed it in "APPS" and 
loaded the tags onto the page correctly.

I just want to be able to set a simple "div" to the button nothing more.

My HTML is as follows:

   

{% csrf_token %}
{{ form.non_field_errors|crispy }}

{{ form.docfile.label_tag|crispy }} {{ form.docfile.help_text|crispy 
}}


{{ form.docfile.errors|crispy }}
{{ form.docfile|crispy }}


   

The error I'm getting is as follows:

'unicode' object has no attribute 'field'

So overall I'm looking to be able to just assign a simple "div" to the 
upload button that I have created without perturbing the button's function.

Is there a way to do this via the ordinary tag?:

 { % crispy form %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20891221-3251-42d5-a6e0-b45d9f5a8190%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django-admin] Popup for inline model

2016-03-09 Thread Trevor Cox
Did you ever find a way to do this? I am working on doing exactly that 
now...

On Sunday, 6 July 2014 02:09:25 UTC-4, ebuild wrote:
>
> In the inline models when using TabularInline, is it possible to use a 
> popup to add/edit an item  when we have a number of fields that can't hold 
> in the page without horizontal scrolling ?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/766c6231-ee32-44c8-a533-0806512a0124%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


partial database restoration

2016-03-09 Thread Mike Dewhirst
I have a Django project oriented around lots of companies and each 
company enters its own data. I need to produce a separate individual 
database backup or dump for each company.


It will be used on request to perform an individual restoration after 
user error has damaged a company's data.


I presume this is a Postgres scripting task or is there a Django recipe?

Thanks for any pointers

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56E0B0A1.6000809%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Django tests on postgresql with fixtures

2016-03-09 Thread Dheerendra Rathor
According to django testing docs - database is flushed after each TestCase. 
It is working fine when I'm using sqlite for testing. But database is not 
flushed when using postgresql and testcases are failing since it is trying 
to load fixtures which have been loaded in previous TestCase. 

Is there any solution to that? Like forcefully flushing database and 
resetting sequences? 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1abd3c7a-68cc-47b3-909f-20b07a69e83e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: partial database restoration

2016-03-09 Thread Bill Freeman
The only problem I can think of with a DB script is that it may have to be
recoded at unpleasant times, such as when you run a migration to take a new
version with a security fix.

If you are going to do it in Django, it would be by saving stuff out to a
fixture, maybe with a custom management command, and that still suffers
from the need to re-write at schema changes.

On Wed, Mar 9, 2016 at 6:24 PM, Mike Dewhirst  wrote:

> I have a Django project oriented around lots of companies and each company
> enters its own data. I need to produce a separate individual database
> backup or dump for each company.
>
> It will be used on request to perform an individual restoration after user
> error has damaged a company's data.
>
> I presume this is a Postgres scripting task or is there a Django recipe?
>
> Thanks for any pointers
>
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/56E0B0A1.6000809%40dewhirst.com.au
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAB%2BAj0szPfR5KZM32R6EePgf%3D9B4gw-gnty2-yNO2O7AWCZG7Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: RegExp problems

2016-03-09 Thread jorrit787
Your improvements work great, thank you. And thank you for the very 
detailed explanations!

On Tuesday, March 8, 2016 at 9:41:11 AM UTC+1, Michal Petrucha wrote:
>
> On Mon, Mar 07, 2016 at 05:44:08PM -0800, jorr...@gmail.com  
> wrote: 
> > I'm trying to replace *[URL]www.link.com[/URL]* with HTML with this 
> regexp: 
> > 
> > topic.text = re.sub("(\[URL\])(.*)(\[\/URL\])", '$2', 
> topic 
> > .text, flags=re.I) 
> > 
> > But it's giving me the following problems: 
> > 
> >1. The $2 capture group is only able to be repeated once, so I get 
> >$2 
> >instead of 
> >www.link.com 
>
> I have my doubts – if you use the standard Python re library, then the 
> way to refer to captured groups is "\1", "\2", etc., not "$1". When I 
> try the code you posted above, I get the following result (i.e., not 
> even the first occurrence of "$2" gets substituted):: 
>
> >>> re.sub("(\[URL\])(.*)(\[\/URL\])", '$2', '[URL]
> www.link.com[/URL]', flags=re.I) 
> '$2' 
>
> In order to make the substitution work for a single occurrence of 
> [URL]...[/URL], you can use the following, which uses "\2" (Also, when 
> writing regular expressions, or other strings that are supposed to 
> contain the backslash character, it is a good idea to write them as 
> raw string literals, i.e. prefix them with a "r", which I've done 
> below; that way, Python won't try to interpret the backslashes as 
> special characters – otherwise, "\2" would become a character with an 
> ASCII value of 2):: 
>
> >>> re.sub(r"(\[URL\])(.*)(\[\/URL\])", r'\2', '[URL]
> www.link.com[/URL]', flags=re.I) 
> 'www.link.com' 
>
> >2. Only the first *[URL]* is matched. Everything after the first 
> *[/URL]* 
> >is simply deleted... 
>
> The solution above gets you halfway there – re.sub will replace all 
> matches by default, the problem here is that the "(.*)" part of your 
> regex will matches everything between the first "[URL]", and the last 
> "[/URL]":: 
>
> >>> re.sub(r"(\[URL\])(.*)(\[\/URL\])", r'\2', '[URL]
> www.link1.com[/URL][URL]www.link2.com[/URL][URL]www.link3.com[/URL]', 
> flags=re.I) 
> 'www.link1.com[/URL][URL]www.link2.com[/URL][URL]
> www.link3.com' 
>
> The reason is that the asterisk operator in a regex is greedy, which 
> means a ".*" will try to match as much as possible. When you use the 
> non-greedy version of the operator (which you get by putting a 
> question mark after the asterisk), you get the result you want:: 
>
> >>> re.sub(r"(\[URL\])(.*?)(\[\/URL\])", r'\2', '[URL]
> www.link1.com[/URL][URL]www.link2.com[/URL][URL]www.link3.com[/URL]', 
> flags=re.I) 
> 'www.link1.com
> www.link2.comwww.link3.com' 
>
>
> You can read an explanation of the difference between greedy and 
> non-greedy regular expressions in the Python docs: 
> https://docs.python.org/2/howto/regex.html#greedy-versus-non-greedy 
>
> Good luck, 
>
> Michal 
>
> > 
> > I hope someone can help me with this. I'm using Python 2.7 if it makes a 
> > difference. 
> > 
> > -- 
> > 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 https://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/fce5a726-8a4c-455a-a978-6ee70d66464e%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6d3e0a68-ec36-4a7a-bcb5-c57a775e8e59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


pgbouncer transaction mode safe with django orm?

2016-03-09 Thread g
Assuming one uses the ORM and avoids raw sql, is it safe to use PgBouncer 
in transaction mode?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0caba87f-718c-46a3-994b-4c33601d8117%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: partial database restoration

2016-03-09 Thread Mike Dewhirst

On 10/03/2016 11:15 AM, Bill Freeman wrote:

The only problem I can think of with a DB script is that it may have to
be recoded at unpleasant times, such as when you run a migration to take
a new version with a security fix.

If you are going to do it in Django, it would be by saving stuff out to
a fixture, maybe with a custom management command, and that still
suffers from the need to re-write at schema changes.


If you were going to do it, which approach would you take?

Thanks Bill

M



On Wed, Mar 9, 2016 at 6:24 PM, Mike Dewhirst mailto:mi...@dewhirst.com.au>> wrote:

I have a Django project oriented around lots of companies and each
company enters its own data. I need to produce a separate individual
database backup or dump for each company.

It will be used on request to perform an individual restoration
after user error has damaged a company's data.

I presume this is a Postgres scripting task or is there a Django recipe?

Thanks for any pointers

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 https://groups.google.com/group/django-users.
To view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/56E0B0A1.6000809%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com
.
To post to this group, send email to django-users@googlegroups.com
.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAB%2BAj0szPfR5KZM32R6EePgf%3D9B4gw-gnty2-yNO2O7AWCZG7Q%40mail.gmail.com
.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56E102FF.1020302%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: execute python through ajax

2016-03-09 Thread Jani Tiainen



On 09.03.2016 15:55, Florian Hoedt wrote:

Hello Django users,
I would like to execute some python code by JS. For example if 
somebody clicks on a openlayers map it should execute a python based 
query and get the result as JSON to render it on the map.

How would I achieve something like this?


Clicking on map does have a handler that is called with coordinates you 
clicked on to. When handler is called you call Django view with those 
coordinates (ajax call maybe). Then you run your query, make response as 
JSON.


I am trying to understand the forms section of the official django 
tutorial without success.


You have to be more specific what part is unclear or what problems you 
have encountered.



--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com 
.
To post to this group, send email to django-users@googlegroups.com 
.

Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a293a0a0-32a0-4333-aefd-d5c15e810a60%40googlegroups.com 
.

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


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56E1134B.4060109%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NAS using Django

2016-03-09 Thread Vayuj Rajan
Actually, I saw a NAS at my friends place so I came up with an idea a of
creating my own using a raspberry pi and an extrernal HDD.
I configured SAMBA and I can access it directly at my computer. But what I
saw there that he was accessing it by using a  website . So basically he
was accessing it from local web server with a storage attached.

So, I wanted to connect my Django web application with Samba File sharing
sever so that I can access it from an IP typed at a web-browser.

On Wed, Mar 9, 2016 at 10:03 PM, Aaron C. de Bruyn 
wrote:

> That's still pretty vague.  What 'file sharing protocols' are you talking
> about specifically?  And what do you mean by wanting to 'connect' the file
> sharing protocols to the application?
>
> There is a PySMB library that will allow your Django application to
> pretend to be a Windows client.
>
> If you're just talking about having the Django application display
> existing files/mounts, there are various built-in tools for that.
>
> You might want to take a look at the FreeNAS project.  They have a Django
> application running as a front-end to their FreeNAS appliance.
>
> -A
>
> On Wed, Mar 9, 2016 at 4:50 AM, Vayuj Rajan  wrote:
>
>> What I wanted to do is to connect the file sharing protocols to this web
>> application i.e the one I will be making it from Django and I wanted to
>> host this application using apache so that it can be hosted locally.
>>
>> On Wednesday, March 9, 2016 at 6:05:51 PM UTC+5:30, Andréas Kühne wrote:
>>>
>>> Hi Vayuj,
>>>
>>> I think you have to be a bit more specific. Django is a web framework,
>>> used for creating web applications and websites. A NAS is usually an array
>>> of harddrives that has different file sharing protocols attached (for
>>> example SMB or NFS).
>>>
>>> It would be possible to implement something like Amazons S3 in django
>>> however if that is what you want?
>>>
>>> Regards,
>>>
>>> Andréas
>>>
>>> 2016-03-09 12:09 GMT+01:00 Vayuj Rajan :
>>>
 Hi,
 I have a query whether we can implement NAS (network attached storage)
 functionality using Django framework?

 --
 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 https://groups.google.com/group/django-users.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/9a9914d7-37cf-4608-892a-2f0a08b001a1%40googlegroups.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/fe72a195-2815-42ef-867c-6245d9e62d1c%40googlegroups.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/E2loEnbFSAs/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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAEE%2BrGpsfTR_SH2jJk%2B3F3PxNLAmvgQYsd%3D9a4FHFSpJu3xvbw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABe4X64FMT3_VyANx5oZA46UOApcvFRB6g5cWrxnHGUOWXcm0A%4