Re: web2py like SQLFORM

2015-06-02 Thread Masklinn

> On 02 Jun 2015, at 04:57, Abhijit Chatterjee  wrote:
> 
> Hello everyone. I am new in django but I have been using web2py for sometime. 
> Do we have anything like SQLFORM that automatically renders the ORM or we 
> have redundantly call each tables and fields?

Tou have not explained what sqlforms are or what they do, but going by the name 
alone that looks like django's modelforms: web forms autogenerated and backed 
by db models.  

-- 
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/B9074E44-5A52-4BE9-A593-89F44FC50FCE%40masklinn.net.
For more options, visit https://groups.google.com/d/optout.


dhango class based views - Saving post data

2015-06-02 Thread Shekar Tippur
Hello,

I am trying to save post data and I get a error. I am trying to use enum 
field.

prefs' is an invalid keyword argument for this function

Request Method:POSTRequest URL:http://127.0.0.1:8000/setPrefs/Django 
Version:1.8.2Exception Type:TypeError

Here is my model

class UserPrefs(models.Model):

Preferences = (
('0','Likes'),
('1','Dislikes'),
('2','Shared'),
('3','Rejected'),
)
user = models.ForeignKey(AuthUser, related_name='Screens')
#user = models.ForeignKey(AuthUser)
address = models.ForeignKey(Address)
prefs = models.CharField(max_length=1,choices=Preferences)
class Meta:
#managed = False
db_table = 'user_pref'

def save(self, *args, **kwargs):
super(Screens, self).save(*args, **kwargs)


Appreciate if someone can shed some light on this.


- Shekar

-- 
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/206ffba0-c578-4bbd-8749-7d174d42cc93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Reuse jquery

2015-06-02 Thread guettli
I guess I am missing something.

Is there no way to load jquery only once per page?

Use case: I have two widgets which need jquery. I want to use
these widgets inside the admin interface and on custom pages.

The admin interface has its own jquery and in jquery.init.js this gets done:

var django = django || {};
django.jQuery = jQuery.noConflict(true);

Since jQuery gets removed from the namespace. This means I can't use
it in the js-files of my widgets. 

I really would like to load jquery only once per page.

Regards,
  Thomas Güttler





-- 
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/4183890d-7279-4c75-bfe1-de30084b15ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Why sqlite time is different from my settings.py TIME_ZONE?

2015-06-02 Thread Hyunseo Yang

I'm using Sqlite for my project database.
I need date and time in my model so i'm using this field.

date = models.DateTimeField()


On the result template (results.html), the time is correct (localtime 
or  TIME_ZONE in my settings.py)
The problem is, when i check the database on Django admin page and sqlite 
db file, it seems like my timezone setting is not applied.(so, maybe UTC)

what is the problem and how could i fix this?

I think the template's parameters are from view, so the timezone.now() is 
correct and passes the right time.
So my guess is that 'date=timezone.now()' passes to sqlite like this: 
'insert into table values (date=datetime('now'))'
and the timezone of sqlite is maybe set to UTC default. 
this is what i'm guessing. am i right? also i do not know how to set sqlite 
database timezone...

p.s On the other side, I also think when we set settings.py TIME_ZONE, 
django would manage all these things.
So don't know where to approach. Spending almost 2 days on this 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/6269c301-d704-4294-863d-bb6c65d7140f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why sqlite time is different from my settings.py TIME_ZONE?

2015-06-02 Thread Dan Tagg
Hi Hyunseo Yang,

SQLite does not save the timezone in the database. If you pass it a
datetime with timezone encoding then it calculates the UTC time that that
time represents and stores that.

It is explained here:
https://www.sqlite.org/lang_datefunc.html

As far as I understand whatever database you are using, Django always
stores datetimes as UTC.

What version of Django are you using as timezone awareness is different for
different versions.

Dan

On 2 June 2015 at 07:23, Hyunseo Yang  wrote:

>
> I'm using Sqlite for my project database.
> I need date and time in my model so i'm using this field.
>
> date = models.DateTimeField()
>
>
> On the result template (results.html), the time is correct (localtime
> or  TIME_ZONE in my settings.py)
> The problem is, when i check the database on Django admin page and sqlite
> db file, it seems like my timezone setting is not applied.(so, maybe UTC)
>
> what is the problem and how could i fix this?
>
> I think the template's parameters are from view, so the timezone.now() is
> correct and passes the right time.
> So my guess is that 'date=timezone.now()' passes to sqlite like this:
> 'insert into table values (date=datetime('now'))'
> and the timezone of sqlite is maybe set to UTC default.
> this is what i'm guessing. am i right? also i do not know how to set
> sqlite database timezone...
>
> p.s On the other side, I also think when we set settings.py TIME_ZONE,
> django would manage all these things.
> So don't know where to approach. Spending almost 2 days on this 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/6269c301-d704-4294-863d-bb6c65d7140f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Wildman and Herring Limited, Registered Office: 52 Great Eastern Street,
London, EC2A 3EP, Company no: 05766374

-- 
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/CAPZHCY6C9D1DD2EPLmtQmJxd7irDgjqr8kytm1%2By-Sg0cPZ%2B1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Graph theory ??

2015-06-02 Thread Rafael E. Ferrero
Hello everyone,

I think to do an app where i would save a directed graph.
The vertex and edges there must be dinamics.
The vertex can represent some Tag or Category... or something.
The edge who links the vertex can be N between two vertex and represent
some event or action... and let me explain here what i need to do:

Suppose you have Vertex1 and Vertex2 and are linked by edge1 from vertex1
to vertex2, edge1 have the action "Add if not exist" and mean that if the
user select the vertex1, the system, automatically add vertex2. Even
further, suppose you have a third vertex related to vertex1 by edge2 and
the action of that edge its "delete if exist" so if the user have,
previously, selected vertex3, when select vertex1, vertex3 would be deleted
by edge2.

Make a model to save the graph it's not a problem (save vertex and edges
and specify what action have every edge)... my problem its develop every
type of event or action for the edges, save that event on database and then
execute that event when needed.

Someone have a recommendation for me?
THANK YOU ALL!!!

--
Rafael E. Ferrero

-- 
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/CAJJc_8V7RiW%2Bsv4-1x9e9a7Evz4_AetSNZoyAqfoFJApwa6JJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Graph theory ??

2015-06-02 Thread Erik Cederstrand
Hi Rafael,

Assuming you have a static and limited set of actions, and they can only be 
defined programmatically, I would do something like this:


class Vertex(models.Model):
 some_field = models.CharField()


class Edge(models.Model):
from = models.ForeignKey(Vertex, related_name='outgoing')
to = models.ForeignKey(Vertex, related_name='incoming')
action = models.CharField(choices=(('action1', 'action1'), ('action2', 
'action2'), ...))

def action1(self):
# Do something here
pass

def action2(self):
# Do something else here
pass

   def run_action(self):
  return getattr(self, self.action)()


When and where to call run_action() would depend on your requirements - either 
in the save() method on Edge, in a signal, or within a view.

If you were looking to define custom actions on the fly via a GUI, you would 
need to define a DSL containing the constructs you allow, create a view where 
the user can compose an AST using the constructs of the DSL, and store the 
resulting AST in the database. When you need to run the action, you would 
translate the AST to Python and run that.

You can also have a look at 
https://www.djangopackages.com/grids/g/trees-and-graphs/ 
 and see if anything 
suits your needs.

Erik


> Den 02/06/2015 kl. 13.47 skrev Rafael E. Ferrero  >:
> 
> Hello everyone,
> 
> I think to do an app where i would save a directed graph. 
> The vertex and edges there must be dinamics.  
> The vertex can represent some Tag or Category... or something. 
> The edge who links the vertex can be N between two vertex and represent some 
> event or action... and let me explain here what i need to do:
> 
> Suppose you have Vertex1 and Vertex2 and are linked by edge1 from vertex1 to 
> vertex2, edge1 have the action "Add if not exist" and mean that if the user 
> select the vertex1, the system, automatically add vertex2. Even further, 
> suppose you have a third vertex related to vertex1 by edge2 and the action of 
> that edge its "delete if exist" so if the user have, previously, selected 
> vertex3, when select vertex1, vertex3 would be deleted by edge2.
> 
> Make a model to save the graph it's not a problem (save vertex and edges and 
> specify what action have every edge)... my problem its develop every type of 
> event or action for the edges, save that event on database and then execute 
> that event when needed.
> 
> Someone have a recommendation for me?
> THANK YOU ALL!!!
> 
> --
> Rafael E. Ferrero
> 
> -- 
> 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/CAJJc_8V7RiW%2Bsv4-1x9e9a7Evz4_AetSNZoyAqfoFJApwa6JJQ%40mail.gmail.com
>  
> .
> For more options, visit https://groups.google.com/d/optout 
> .

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


Django CMS/ Framework for Banking /Financial service

2015-06-02 Thread Swapnil Bhadade
Which are Django packages for full stack development of an e-banking web 
app based on P2P model. Any resources / frameworks would be of help.
Best

-- 
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/4d6da124-9d65-436e-933c-1ae5c601765b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Graph theory ??

2015-06-02 Thread Rafael E. Ferrero
Thanks Erik, Defining custom actions its what i try to do!! because, the
user can add some custom type of Action and he need to specify what to do
with.

With this, the user can perform his own graph and rules to control the
vertex.

For example, a Contact of the business can be a Provider or a Customer for
the business and, also, can be a Person or another Company but if is a
Company he can't be a Person... if is a Contact, and a Provider and a
Person he could be a Medic, but if is a Medic he can't be treated like a
simple Provider...
So, Contact, Provider, Customer, Person, Medic are the vertex and you need
actions to control the automation of the graph, and the actions can be
change from one implementation another.

Like you say, maybe usind DSL and AST i can execute custom actions using
Signal

THANKS A LOT!!

and now Do you think that this could be a good approach? or you suggest
something better ??


--
Rafael E. Ferrero

2015-06-02 10:04 GMT-03:00 Erik Cederstrand :

> Hi Rafael,
>
> Assuming you have a static and limited set of actions, and they can only
> be defined programmatically, I would do something like this:
>
>
> class Vertex(models.Model):
>  some_field = models.CharField()
>
>
> class Edge(models.Model):
> from = models.ForeignKey(Vertex, related_name='outgoing')
> to = models.ForeignKey(Vertex, related_name='incoming')
> action = models.CharField(choices=(('action1', 'action1'), ('action2',
> 'action2'), ...))
>
> def action1(self):
> # Do something here
> pass
>
> def action2(self):
> # Do something else here
> pass
>
>def run_action(self):
>   return getattr(self, self.action)()
>
>
> When and where to call run_action() would depend on your requirements -
> either in the save() method on Edge, in a signal, or within a view.
>
> If you were looking to define custom actions on the fly via a GUI, you
> would need to define a DSL containing the constructs you allow, create a
> view where the user can compose an AST using the constructs of the DSL, and
> store the resulting AST in the database. When you need to run the action,
> you would translate the AST to Python and run that.
>
> You can also have a look at
> https://www.djangopackages.com/grids/g/trees-and-graphs/ and see if
> anything suits your needs.
>
> Erik
>
>
> Den 02/06/2015 kl. 13.47 skrev Rafael E. Ferrero  >:
>
> Hello everyone,
>
> I think to do an app where i would save a directed graph.
> The vertex and edges there must be dinamics.
> The vertex can represent some Tag or Category... or something.
> The edge who links the vertex can be N between two vertex and represent
> some event or action... and let me explain here what i need to do:
>
> Suppose you have Vertex1 and Vertex2 and are linked by edge1 from vertex1
> to vertex2, edge1 have the action "Add if not exist" and mean that if the
> user select the vertex1, the system, automatically add vertex2. Even
> further, suppose you have a third vertex related to vertex1 by edge2 and
> the action of that edge its "delete if exist" so if the user have,
> previously, selected vertex3, when select vertex1, vertex3 would be deleted
> by edge2.
>
> Make a model to save the graph it's not a problem (save vertex and edges
> and specify what action have every edge)... my problem its develop every
> type of event or action for the edges, save that event on database and then
> execute that event when needed.
>
> Someone have a recommendation for me?
> THANK YOU ALL!!!
>
> --
> Rafael E. Ferrero
>
> --
> 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/CAJJc_8V7RiW%2Bsv4-1x9e9a7Evz4_AetSNZoyAqfoFJApwa6JJQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/A560D552-8EF4-4A6C-A763-E3613CC3B647%40cederstrand.dk
> 
> .
> For more options, vis

Re: Migrate command does not respect options for db connections?

2015-06-02 Thread George Silva
Any news? Hello?

On Sat, May 30, 2015 at 4:28 PM, George Silva 
wrote:

> Context:
>
> Django 1.7.1
> PostgreSQL 9.4
>
> I have the following database entry in settings:
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.contrib.gis.db.backends.postgis',
> 'NAME': 'xpto',
> 'USER': 'postgres',
> 'PASSWORD': 'postgres',
> 'HOST': 'localhost',
> 'PORT': '5432',
> 'OPTIONS': {
> 'options': '-c search_path=xpto,public'
> }
> }
> }
>
>
> And the following model:
>
> class ModelA(models.Model):
> att_a = models.CharField(max_length=10)
>
> I' just created a migration with makemigrations for this app. It does not
> have any indication of schema, whatsoever.
>
> When I ran the migration, with migrate, the table ended up on the public
> schema.
>
> Bug?
>
> --
> George R. C. Silva
> Sigma Geosistemas LTDA
> 
> http://www.sigmageosistemas.com.br/
>



-- 
George R. C. Silva
Sigma Geosistemas LTDA

http://www.sigmageosistemas.com.br/

-- 
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/CAGyPVTttnUey%2B%2BwqemEw6FWc%2Bav2omQOFNpG-Beo1Vpqm_XXLw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Update dates in models auto

2015-06-02 Thread Juliano Araújo Farias
Dears,

First I thx for ur attentions... and I novete in Django... but a have a 
question...

Second:
I have this in my model:

class Actionplan(models.Model):

date_start_preview = models.DateField('Data Prevista Inicial', 
blank=True, null=True)
date_end_preview = models.DateField('Data Prevista Final', blank=True, 
null=True)
date_start = models.DateField('Data Real Inicial', blank=True, 
null=True)
date_end = models.DateField('Data Real Final', blank=True, null=True)

class Actions(models.Model):

date_start_preview = models.DateField('Data Prevista Inicial', 
blank=True)
date_end_preview = models.DateField('Data Prevista Final', blank=True)
date_start = models.DateField('Data Real Inicial', blank=True)
date_end = models.DateField('Data Real Final', blank=True)

actionplan = models.ForeignKey(Actionplan, verbose_name='Ações', 
related_name='actions')


---
and I want in admin do:

When the user create a action, the dates in actionplans update with the sum 
dates...


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/2309e9e6-8289-4ea6-865e-9095bddb9fe8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: dhango class based views - Saving post data

2015-06-02 Thread James Schneider
Can you post the entire traceback for the error, and the view code as well?

-James
On Jun 2, 2015 12:47 AM, "Shekar Tippur"  wrote:

> Hello,
>
> I am trying to save post data and I get a error. I am trying to use enum
> field.
>
> prefs' is an invalid keyword argument for this function
>
> Request Method:POSTRequest URL:http://127.0.0.1:8000/setPrefs/Django
> Version:1.8.2Exception Type:TypeError
>
> Here is my model
>
> class UserPrefs(models.Model):
>
> Preferences = (
> ('0','Likes'),
> ('1','Dislikes'),
> ('2','Shared'),
> ('3','Rejected'),
> )
> user = models.ForeignKey(AuthUser, related_name='Screens')
> #user = models.ForeignKey(AuthUser)
> address = models.ForeignKey(Address)
> prefs = models.CharField(max_length=1,choices=Preferences)
> class Meta:
> #managed = False
> db_table = 'user_pref'
>
> def save(self, *args, **kwargs):
> super(Screens, self).save(*args, **kwargs)
>
>
> Appreciate if someone can shed some light on this.
>
>
> - Shekar
>
>  --
> 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/206ffba0-c578-4bbd-8749-7d174d42cc93%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/CA%2Be%2BciUY1DRzRCHJSBjqFK-XXEqkMZz6zjMkxw3bvrmkJ0DF9A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reuse jquery

2015-06-02 Thread Bill Freeman
Are you saying that you can't access it as django.jQuery ?

On Tue, Jun 2, 2015 at 4:22 AM, guettli  wrote:

> I guess I am missing something.
>
> Is there no way to load jquery only once per page?
>
> Use case: I have two widgets which need jquery. I want to use
> these widgets inside the admin interface and on custom pages.
>
> The admin interface has its own jquery and in jquery.init.js this gets
> done:
>
> var django = django || {};
> django.jQuery = jQuery.noConflict(true);
>
> Since jQuery gets removed from the namespace. This means I can't use
> it in the js-files of my widgets.
>
> I really would like to load jquery only once per page.
>
> Regards,
>   Thomas Güttler
>
>
>
>
>
>  --
> 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/4183890d-7279-4c75-bfe1-de30084b15ca%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%2BAj0u_adaZ2Z%2BvF3Smny%3Dxwxi%2B7MDkJdeQmJ92M%3DckB%2Bx6zw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: dhango class based views - Saving post data

2015-06-02 Thread Shekar Tippur
Here is the trace:

Traceback:

File 
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/handlers/base.py"
 
in get_response

  132. response = wrapped_callback(request, 
*callback_args, **callback_kwargs)

File 
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/views/decorators/csrf.py"
 
in wrapped_view

  58. return view_func(*args, **kwargs)

File 
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/views/generic/base.py"
 
in view

  71. return self.dispatch(request, *args, **kwargs)

File 
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/rest_framework/views.py"
 
in dispatch

  451. response = self.handle_exception(exc)

File 
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/rest_framework/views.py"
 
in dispatch

  448. response = handler(request, *args, **kwargs)

File "/Users//PycharmProjects///views.py" in post

  88. serializer.save()

File 
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/rest_framework/serializers.py"
 
in save

  165. self.instance = self.create(validated_data)

File "/Users//PycharmProjects///modelserializer.py" in create 

  48. return Screens.objects.create(**validated_data)

File 
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/models/manager.py"
 
in manager_method

  127. return getattr(self.get_queryset(), name)(*args, 
**kwargs)

File 
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/models/query.py"
 
in create

  346. obj = self.model(**kwargs)

File 
"/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/models/base.py"
 
in __init__

  480. raise TypeError("'%s' is an invalid keyword argument 
for this function" % list(kwargs)[0])


Exception Type: TypeError at //setPrefs/

Exception Value: 'prefs' is an invalid keyword argument for this function

*and View:*

class AddToUserProfile(generics.CreateAPIView):

permission_classes = 
(permissions.IsAuthenticatedOrReadOnly,IsOwnerOrReadOnly)

serializer_class = UserPrefSerializer

queryset = UserPrefs.objects.all()

lookup_field = 'user_id'

#def create(self,request,*args, **kwargs):

def post(self, request, *args, **kwargs):

serializer = UserPrefSerializer(data=request.data)

print (repr(serializer))

user=request.user

if serializer.is_valid():

serializer.save()

return Response(serializer.data, status=status.HTTP_201_CREATED)

else:

return Response(serializer.errors, 
status=status.HTTP_400_BAD_REQUEST)

-- 
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/75f93eda-9e16-42ef-a4df-119bb1482f45%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reuse jquery

2015-06-02 Thread guettli
Hi,

we had a very strange problem with the ordering of the JS files.

the jquery.init.js from django removed the jquery from us which had 
jquery-ui loaded.

The problem is solved.

  Thomas Güttler

Am Dienstag, 2. Juni 2015 17:24:56 UTC+2 schrieb ke1g:
>
> Are you saying that you can't access it as django.jQuery ?
>
> On Tue, Jun 2, 2015 at 4:22 AM, guettli > 
> wrote:
>
>> I guess I am missing something.
>>
>> Is there no way to load jquery only once per page?
>>
>> Use case: I have two widgets which need jquery. I want to use
>> these widgets inside the admin interface and on custom pages.
>>
>> The admin interface has its own jquery and in jquery.init.js this gets 
>> done:
>>
>> var django = django || {};
>> django.jQuery = jQuery.noConflict(true);
>>
>> Since jQuery gets removed from the namespace. This means I can't use
>> it in the js-files of my widgets. 
>>
>> I really would like to load jquery only once per page.
>>
>> Regards,
>>   Thomas Güttler
>>
>>
>>
>>
>>
>>  -- 
>> 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/4183890d-7279-4c75-bfe1-de30084b15ca%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/77bf69b5-ac81-48c9-a4e2-518802356b70%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Reduce number of calls to database

2015-06-02 Thread Cherie Pun
Hi,

I am new to Django and I am performing some iteration on a queryset. When I 
use django_debug_toolbar to look at the SQL usage, I realised that Django 
is actually calling the database once in each iteration. Is there a way to 
make it call the database only once and somehow store it locally so that I 
can iterate on it?

Code:
for level_id in levels_id:
   levels.append(get_object_or_404(Level, id=level_id))


I am trying this modified code, but it seems that it's still calling the 
same number of times.

levels_dict = repr(Level.objects.values('id', 'name'))
for level_id in levels_id:
levels.append(levels_dict.get(id=level_id).get('name'))

I am trying to use this pattern in quite a few places, where I want to get 
some data from a list of objects retrieved from the database and iterate 
over them. 
I would be happy to provide any missing information.

Could anyone kindly help me out? Cheers!

-- 
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/631e4503-c3ff-432a-9f6b-b0f6b6105b26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Reduce number of sql calls to database

2015-06-02 Thread Cherie Pun
Hi,

I am new to Django and I am trying to reduce the number of calls to 
database as it's slowing down the app. I am performing iteration over the 
queryset and I used django_debug_toolbar to check the number of queries 
made, and the number is huge. It looks like django is making a query call 
to the db in each iteration. Is there a way to make it only send one query 
and then store the result locally and iterate over it?

Code:
for level_id in levels_id:
levels.append(get_object_or_404(Level, id=level_id))

I have been trying out this code, but it seems that the number of sql 
queries is still the same.
levels_dict = Level.objects.values('id', 'name')
for level_id in levels_id:
levels.append(levels_dict.get(id=level_id).get('name'))

I am using the same pattern in a few places to get data from each of the 
object in the queryset, is there a way to improve the performance? I am 
happy to provide any missing information. Cheers!

P.S. I tried to post just now but the post seems to be missing so I am 
trying again, hopefully I didn't post twice!

-- 
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/3745df48-5278-4b59-ad1e-f03ba855da15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reduce number of calls to database

2015-06-02 Thread Simon Charette
Hi Cherie,

A `id__in` queryset lookup should issue a single query.

levels = Level.objects.filter(id__in=level_ids)

Cheers,
Simon

Le mardi 2 juin 2015 11:42:19 UTC-4, Cherie Pun a écrit :
>
> Hi,
>
> I am new to Django and I am performing some iteration on a queryset. When 
> I use django_debug_toolbar to look at the SQL usage, I realised that Django 
> is actually calling the database once in each iteration. Is there a way to 
> make it call the database only once and somehow store it locally so that I 
> can iterate on it?
>
> Code:
> for level_id in levels_id:
>levels.append(get_object_or_404(Level, id=level_id))
>
>
> I am trying this modified code, but it seems that it's still calling the 
> same number of times.
>
> levels_dict = repr(Level.objects.values('id', 'name'))
> for level_id in levels_id:
> levels.append(levels_dict.get(id=level_id).get('name'))
>
> I am trying to use this pattern in quite a few places, where I want to get 
> some data from a list of objects retrieved from the database and iterate 
> over them. 
> I would be happy to provide any missing information.
>
> Could anyone kindly help me out? Cheers!
>
>

-- 
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/1a8668df-fb0a-47a9-8774-d800b510abdc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reduce number of sql calls to database

2015-06-02 Thread Larry Martell
On Tue, Jun 2, 2015 at 11:48 AM, Cherie Pun  wrote:
> Hi,
>
> I am new to Django and I am trying to reduce the number of calls to database
> as it's slowing down the app. I am performing iteration over the queryset
> and I used django_debug_toolbar to check the number of queries made, and the
> number is huge. It looks like django is making a query call to the db in
> each iteration. Is there a way to make it only send one query and then store
> the result locally and iterate over it?
>
> Code:
> for level_id in levels_id:
> levels.append(get_object_or_404(Level, id=level_id))
>
> I have been trying out this code, but it seems that the number of sql
> queries is still the same.
> levels_dict = Level.objects.values('id', 'name')
> for level_id in levels_id:
> levels.append(levels_dict.get(id=level_id).get('name'))
>
> I am using the same pattern in a few places to get data from each of the
> object in the queryset, is there a way to improve the performance? I am
> happy to provide any missing information. Cheers!

How about this:

Levels.objects.filter(id__in= levels_id)

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


Help needed for big django project (crm+shop+cms+autoresponder). What apps shall I build on?

2015-06-02 Thread ThomasTheDjangoFan
Hi guys,

I am planning on a bigger django project with a lot of functionality.

The thing is that I have NO experience with existing django-apps that might 
fit and definetly need your help.

Can you give me a hint which existing (and stable) django-apps I could use 
as a foundation for my project?

Those are the functions that I would like to implement (ordered by priority)
 1. *CRM* system
 -> client database
 -> ticket system (client communication including sending emails from 
backend)
 2. *Shop*
 -> calender booking system
 -> PDF billing generation
 3. email *autoresponder* system
 4. *CMS* functionality would also help

I would be really thankful if you could guide me to the right direction.
Which way shall I go?

Kind regards
Thomas

-- 
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/14165632-4db7-4d8c-a30e-827c3730ca3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Trouble w. Setting Up Virtual Env.

2015-06-02 Thread Steve Burrus
*I hasve repeatedly tried now to set up the Django Virtual Environment 
without any success! Just what am I doing wrong anyway?? I am at my "wit's 
end"  trying to figure out what the specific problem is.*
  
*c:\Users\SteveB\Desktop>virtualenv steve1*
*Using base prefix 'C:\\Python 3.5'*
*New python executable in steve1\Scripts\python.exe*
*Installing setuptools, pip, wheel...*
*  Complete output from command c:\Users\SteveB\Desk...1\Scripts\python.exe 
-c "import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:*
*  Ignoring indexes: https://pypi.python.org/simple*
*Collecting setuptools*
*  The repository located at None is not a trusted or secure host and is 
being ignored. If this repository is available via HTTPS it is recommended 
to use HTTPS instead, otherwise you may silence this warning and allow it 
anyways with '--trusted-host None'.*
*  The repository located at None is not a trusted or secure host and is 
being ignored. If this repository is available via HTTPS it is recommended 
to use HTTPS instead, otherwise you may silence this warning and allow it 
anyways with '--trusted-host None'.*
*  The repository located at None is not a trusted or secure host and is 
being ignored. If this repository is available via HTTPS it is recommended 
to use HTTPS instead, otherwise you may silence this warning and allow it 
anyways with '--trusted-host None'.*
*  The repository located at None is not a trusted or secure host and is 
being ignored. If this repository is available via HTTPS it is recommended 
to use HTTPS instead, otherwise you may silence this warning and allow it 
anyways with '--trusted-host None'.*
*  The repository located at None is not a trusted or secure host and is 
being ignored. If this repository is available via HTTPS it is recommended 
to use HTTPS instead, otherwise you may silence this warning and allow it 
anyways with '--trusted-host None'.*
*  The repository located at None is not a trusted or secure host and is 
being ignored. If this repository is available via HTTPS it is recommended 
to use HTTPS instead, otherwise you may silence this warning and allow it 
anyways with '--trusted-host None'.*
*  Could not find a version that satisfies the requirement setuptools (from 
versions: )*
*No matching distribution found for setuptools*
**
*...Installing setuptools, pip, wheel...done.*
*Traceback (most recent call last):*
*  File "C:\Python 3.5\lib\runpy.py", line 170, in _run_module_as_main 
"__main__", mod_spec)*
*  File "C:\Python 3.5\lib\runpy.py", line 85, in _run_code exec(code, 
run_globals)*
*  File "C:\Python 3.5\Scripts\virtualenv.exe\__main__.py", line 9, in 
*
*  File "C:\Python 3.5\lib\site-packages\virtualenv.py", line 832, in main 
symlink=options.symlink)*
*  File "C:\Python 3.5\lib\site-packages\virtualenv.py", line 1004, in 
create_environment*
*install_wheel(to_install, py_executable, search_dirs)*
*  File "C:\Python 3.5\lib\site-packages\virtualenv.py", line 969, in 
install_wheel*
*'PIP_NO_INDEX': '1'*
*  File "C:\Python 3.5\lib\site-packages\virtualenv.py", line 910, in 
call_subprocess*
*% (cmd_desc, proc.returncode))*
*OSError: Command c:\Users\SteveB\Desk...1\Scripts\python.exe -c "import 
sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel failed with 
error code 1*

-- 
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/898eb3b7-a396-40d3-8ec6-4815d48c2263%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


i have got a forbidden error in my project plz help for solve it

2015-06-02 Thread DHaval Joshi
i try to solve forbidden error bt its not working .
i m new  in django so plz help me to solv this error 

i attach 
my templet
views.py 
and url.py 
if u need more thing then reply me i send it to u.. 

-- 
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/0c3193d4-afff-4376-a7c2-75fc4ecf1460%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Title: MBRS System

{% load staticfiles %}

  
  
	

		
			

	Toggle navigation
	
	
	


	


			

	{% csrf_token %} 
	
		
			

	Medical
	Reimbursement
	System

			
		
		
			Employee ID
			
		
		
			Password
			
		
		
			 Log in
		
		
			
Sign up
			

	

			
		

	
	

	
	
		
			

 




			
		
		
			
2
1
3
4
5
6
			
		
		
		
	
	
	
	
	
	
	
	
	
	
  

from django.shortcuts import render,HttpResponse,render_to_response
from .models import login
from django.views.decorators.csrf import csrf_protec

def home(request):
return render_to_response('home.html')

def log(request):
 
return HttpResponse(str(login.objects.all()))


urls.pyc
Description: application/python-code


new to Django having models/views/templates question

2015-06-02 Thread Chris Strasser
Hi am plugging away at learning Django and have done well so far (thanks to 
great documentation and Stackoverflow) but I have run into a problem that i 
cant seem to figure out. 


I have a model that refers to another model that refers to another model. 

example :

Class ServiceOrder 
id -integer
   customer location = foreign key to location 

def __str__(self):
return self.stid

class Location:
   id -integer
   address -char
   customer- foreign key to customer

q= '%s %s %s %s ' %(self.addr1, self.addr2, self.city, self.country)
return unicode(q).encode('utf-8')

Class Customer
id=int
name- char
return unicode(self).encode('utf-8')

I have a template that lists the service orders view is below:


def serviceorder_list(request, status = 'Closed'):
ist = ServiceOrder.objects.filter(status = status, 
stid__lte=20239).select_related('customer_location__customer')
#stid__lte 20239 to fix database error ... i have existing data that has 
its own issues...
count = order_list.count()
context ={'list': sto_list, 'count': count}
  
return render(request, 'order/listview.html', context)


in my listview.html

{% for item  in list %}
{% if item.project %}
{{item.stid}}
{{item.project}}
{{item.customer_location.name}}  
-- 2 questions here  1) it throws an error on customer 
names that have accents etc ...  

{{item.notes}} 
 
2) i am confused about how to properly referenece the 
customer name or anything else that is not in the Service order  model. 
   
{{item.person_responsible}}
{{item.entrydate|date:'M-d-y'}}
  {{item.status}}
  {{item.billing}}  
  


I have read the docs many times and the more i read the more i know that i 
don't know ... any help would be appreciated


Thanks 
 
 

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


All Urls lead to home.html

2015-06-02 Thread Jariel Arias
For some reason every time I try to go to my admin page it takes me back to 
my home.html which is just :

 Hi There 

anyone know why this could be happening?

-- 
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/bec8b43b-0c54-425c-b4f9-f98993539efd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: All Urls lead to home.html

2015-06-02 Thread Thomas Murphy
Hi Jariel,

What URI are you accessing to get to your admin page?

Can you show us your urls.py?

Best,
Thomas

On Tue, Jun 2, 2015 at 1:46 PM, Jariel Arias  wrote:

> For some reason every time I try to go to my admin page it takes me back
> to my home.html which is just :
>
>  Hi There 
>
> anyone know why this could be happening?
>
> --
> 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/bec8b43b-0c54-425c-b4f9-f98993539efd%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/CALgvumXmbvDwK7LDVhNWeMsmfOVEQO1H2pr4uyDunwogfb%3D1zw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: new to Django having models/views/templates question

2015-06-02 Thread James Schneider
Can you post the error and traceback? It sounds like you may have an
encoding issue.

-James
On Jun 2, 2015 11:00 AM, "Chris Strasser"  wrote:

> Hi am plugging away at learning Django and have done well so far (thanks
> to great documentation and Stackoverflow) but I have run into a problem
> that i cant seem to figure out.
>
>
> I have a model that refers to another model that refers to another model.
>
> example :
>
> Class ServiceOrder
> id -integer
>customer location = foreign key to location
>
> def __str__(self):
> return self.stid
>
> class Location:
>id -integer
>address -char
>customer- foreign key to customer
>
> q= '%s %s %s %s ' %(self.addr1, self.addr2, self.city,
> self.country)
> return unicode(q).encode('utf-8')
>
> Class Customer
> id=int
> name- char
> return unicode(self).encode('utf-8')
>
> I have a template that lists the service orders view is below:
>
>
> def serviceorder_list(request, status = 'Closed'):
> ist = ServiceOrder.objects.filter(status = status,
> stid__lte=20239).select_related('customer_location__customer')
> #stid__lte 20239 to fix database error ... i have existing data that has
> its own issues...
> count = order_list.count()
> context ={'list': sto_list, 'count': count}
>
> return render(request, 'order/listview.html', context)
>
>
> in my listview.html
>
> {% for item  in list %}
> {% if item.project %}
> {{item.stid}}
> {{item.project}}
> {{item.customer_location.name}}
> -- 2 questions here  1) it throws an error on customer
> names that have accents etc ...
>
> {{item.notes}}
> 2) i am confused about how to properly referenece the
> customer name or anything else that is not in the Service order  model.
>
> {{item.person_responsible}}
> {{item.entrydate|date:'M-d-y'}}
>   {{item.status}}
>   {{item.billing}}
>   
>
>
> I have read the docs many times and the more i read the more i know that i
> don't know ... any help would be appreciated
>
>
> Thanks
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/76ad4dab-574e-4867-96b6-96be02e8a739%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/CA%2Be%2BciUCqh8uCqSA9JNh18XUWO8FfDnjpCS5V_5ksNXoT6VqOg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: non DB related fiels in model to appear in a form

2015-06-02 Thread Chris Strasser
hi Reiner I think what you want to do is controlled in the view not the 
model. 

in your view do something like this:

context = {'form':form, 'infotext': "some informational text"}  
 return render(request,'form.html', context)


then in your template you can refer to it as follows:

{{form.name}}

{{ infotext}}

{{form.Ans1_OKH}} 
{{form.Ans2_OKH}} 
{{form.Ans3_OKH}} 

hope that helps ...

On Monday, June 1, 2015 at 7:03:14 AM UTC-4, wigm...@gmail.com wrote:
>
>
> Hello all, 
>
> how can I add a string in the model that would appear in the output form 
> exactly
> on the position from the model as text e.g. in a Paragraph. Is it possible 
> to
> create a non DB related Field in models for that?
>
> Example how I would like it to be :
>
> in models.py
>
> class Example(models.Model):
> Name   = 
> models.CharField(max_length=100,blank=True,null=True) 
> # Now a field that needs no DB representation
> Question_TIW = 
> models.TextInAParagraphField(verbose_name='Some informational Text')
> # or assign verbose_name later in view
> Ans1_OKH   = models.BooleanField(default=False)
> Ans2_OKH   = models.BooleanField(default=False)
> Ans3_OKH   = models.BooleanField(default=False)
>
> Result should be a Form 
>
> with a Name input, 
> followed by 'Some informational Text',
> followed by Select Buttons to click
> followed by a submit button
>
> kind regards 
> Reiner
>

-- 
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/4f0783a8-62bf-4e41-95e6-d54751016eb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: dhango class based views - Saving post data

2015-06-02 Thread Shekar Tippur
Just to add, if I use a curl request 

curl -H  "Authorization: Bearer $usertoken" -H "Content-Type: 
application/json" -X POST -d 
'{"user":"foo1","stock":"XYZ","prefs":"Likes"}' http://${endpoint}/addPrefs

I get a error: {"prefs":["\"Likes\" is not a valid choice."]}

If I use

curl -H  "Authorization: Bearer $usertoken" -H "Content-Type: 
application/json" -X POST -d '{"user":"foo1","stock":"XYZ","prefs":"1"}' 
http://${endpoint}/addPrefs

I get the above trace. 

-- 
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/7ca2a02f-596e-40da-9a16-2b2011871e02%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: new to Django having models/views/templates question

2015-06-02 Thread Chris Strasser
Hi James thanks for the response... 


this line: {{item.customer_location.customer}} 

. worked this morning and all last week  now gives this error:

RuntimeError at /sto/ 

maximum recursion depth exceeded while calling a Python object

 Request Method: GET  Request URL: http://10.0.0.102:8080/sto/  Django 
Version: 1.8  Exception Type: RuntimeError  Exception Value




maximum recursion depth exceeded while calling a Python object
 

I can reproduce the encoding error but i forget how to get there at the moment 
...





On Tuesday, June 2, 2015 at 2:00:22 PM UTC-4, Chris Strasser wrote:
>
> Hi am plugging away at learning Django and have done well so far (thanks 
> to great documentation and Stackoverflow) but I have run into a problem 
> that i cant seem to figure out. 
>
>
> I have a model that refers to another model that refers to another model. 
>
> example :
>
> Class ServiceOrder 
> id -integer
>customer location = foreign key to location 
>
> def __str__(self):
> return self.stid
>
> class Location:
>id -integer
>address -char
>customer- foreign key to customer
>
> q= '%s %s %s %s ' %(self.addr1, self.addr2, self.city, 
> self.country)
> return unicode(q).encode('utf-8')
>
> Class Customer
> id=int
> name- char
> return unicode(self).encode('utf-8')
>
> I have a template that lists the service orders view is below:
>
>
> def serviceorder_list(request, status = 'Closed'):
> ist = ServiceOrder.objects.filter(status = status, 
> stid__lte=20239).select_related('customer_location__customer')
> #stid__lte 20239 to fix database error ... i have existing data that has 
> its own issues...
> count = order_list.count()
> context ={'list': sto_list, 'count': count}
>   
> return render(request, 'order/listview.html', context)
>
>
> in my listview.html
>
> {% for item  in list %}
> {% if item.project %}
> {{item.stid}}
> {{item.project}}
> {{item.customer_location.name}}  
> -- 2 questions here  1) it throws an error on customer 
> names that have accents etc ...  
> 
> {{item.notes}}   
>
> 2) i am confused about how to properly referenece the 
> customer name or anything else that is not in the Service order  model. 
>
> {{item.person_responsible}}
> {{item.entrydate|date:'M-d-y'}}
>   {{item.status}}
>   {{item.billing}}  
>   
>
>
> I have read the docs many times and the more i read the more i know that i 
> don't know ... any help would be appreciated
>
>
> Thanks 
>  
>  
>

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


Re: dhango class based views - Saving post data

2015-06-02 Thread James Schneider
I just looked over your model again. Your save() override has a
super(Screens,...) reference, which doesn't match the model class.

That may explain why you are getting the invalid parameters error, since
you are probably calling the wrong save function from a different class.

I'd remove that save() override entirely.

-James
Just to add, if I use a curl request

curl -H  "Authorization: Bearer $usertoken" -H "Content-Type:
application/json" -X POST -d
'{"user":"foo1","stock":"XYZ","prefs":"Likes"}' http://${endpoint}/addPrefs

I get a error: {"prefs":["\"Likes\" is not a valid choice."]}

If I use

curl -H  "Authorization: Bearer $usertoken" -H "Content-Type:
application/json" -X POST -d '{"user":"foo1","stock":"XYZ","prefs":"1"}'
http://${endpoint}/addPrefs

I get the above trace.

 --
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/7ca2a02f-596e-40da-9a16-2b2011871e02%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/CA%2Be%2BciVMY4FmpfrSoZEG8njPj%2B%3DJiTjMSAPK9YXPCyXUQyiJGA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: dhango class based views - Saving post data

2015-06-02 Thread Shekar Tippur
James,

I have commented save in model code. I have also changed the prefs field to 
be char(20) for now.

I still get 

'prefs' is an invalid keyword argument for this function

- Shekar



-- 
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/99897c3a-1126-426c-be49-1e913ded3eeb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-summernote WYSIWYG editor: mixing modelForm and model, problem with Images

2015-06-02 Thread hemulin
Hi,
not sure what I've done but I don't get the error anymore, instead I got 
nothing. No error, no image in the preview and no image after the saving 
and displaying the article.

To your questions, yes and yes. I can find the image in the server (under 
static/media/django-summernote/), and I can find the image 
in the DB.

Interestingly, while using the "load image from URL" option in the 
summernote dialog, the url is inserted well, both in the preview and in the 
displayed article ( tag with the url src in the right place in 
form.cleaned_data['text']).

Evidently the problem exists only when uploading a local image. Which leads 
me to the assumption that there is a problem with my media settings...

What I have is this:
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(PROJECT_PATH, "static", "media")
MEDIA_URL = "media/"

url(r'^media/(?P.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT, 'show_indexes': True
}),

I can access the uploaded images via 'media/' and browsing through the 
folders, so I thought it's set up well, no I'm not so sure.

Any idea what's going on here?

On Tuesday, June 2, 2015 at 6:44:53 AM UTC+3, James Schneider wrote:
>
> Can you post the full error you're receiving? The 'blah blah blah' is 
> probably the most important. A mention of MIME types likely means that the 
> image is not uploading correctly. Can you actually find the image on the 
> server? Or a record of it in the database?
>
> -James
>
>
>
> On Jun 1, 2015 6:56 PM, "hemulin" > 
> wrote:
>
>> (noob warning)
>>
>> I wanted to use summernote within a model but without using the default 
>> modelForm.
>> I ended up mixing the two like this (can't have widgets on model 
>> field...):
>> In models I have
>>
>> class Article(models.Model):
>>  """Represents a wiki article"""
>>  title = models.CharField(max_length=100)
>>  slug = models.SlugField(max_length=50, unique=True)
>>  text = models.TextField()
>>  author = models.ForeignKey(User)
>>  created_on = models.DateTimeField(auto_now_add=True)
>>  objects = models.Manager()
>>  tags = TaggableManager(through=TaggedArticle)
>>
>> class ArticleForm(forms.ModelForm):
>>  class Meta:
>>   model = Article
>>   fields = ['text']
>>   widgets = {
>> 'text': SummernoteWidget(),
>>   }
>>
>> After having the right display while serving the template, I attempt to 
>> save the Article like this:
>> in views, a part of the saving method:
>>
>> form = ArticleForm(request.POST or None)
>> if form.is_valid():
>> #import pdb; pdb.set_trace()
>> article = Article()
>> article.text = form.cleaned_data['text'] # THIS IS MY HACKISH WAY OF 
>> FETCHING THE CONTENT
>> article.author = request.user
>> article.title = request.POST['title']
>> article.save()
>> if request.POST.has_key('tags'): #add relevant ones
>>   article_tags = request.POST.getlist('tags')
>>   article_tags = [tag for tag in article_tags]
>>   article.tags.add(*article_tags)
>> return HttpResponse("Article saved successfully")
>>
>> 1) I have everything configured (MEDIA_ROOT, MEDIA_URL, summernote url as 
>> described in the setup)
>> 2) The widget is displayed well within iframe
>> 3) When uploading an image I get the "mime interpreted as text blah blah 
>> blah" error
>> 4) After saving, when displaying the article, the text is displayed well 
>> with all the markup but no image is displayed
>> 5) For every image I try to add to an article, the image appear in 
>> django-summernote//.
>>
>> Finally, how would you suggest me to solve the problem and having the 
>> images uploaded and displayed correctly in the resulted article text?
>>
>> Cheers.
>>
>> -- 
>> 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/1d2c3458-2275-48c8-b9b8-bc9ccbcb5e57%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/de7c9520-c772-4b4b-9932-b5da56c621a9%40googlegroups.com.
For more options, visit https://groups.goo

why i failed to install django?

2015-06-02 Thread mnz hz


IOError: [Errno 22] invalid mode ('wb') 


detailed error message is as follows:


http://pastie.org/10219723#1,21

-- 
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/ce682fe6-1151-49e3-857d-cb8244491b6d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: why i failed to install django?

2015-06-02 Thread Gergely Polonkai
This doesn’t seem to be a Django issue to me… Can you install any other
packages with pip?

2015-06-02 20:12 GMT+02:00 mnz hz :

>
>
> IOError: [Errno 22] invalid mode ('wb')
>
>
> detailed error message is as follows:
>
>
> http://pastie.org/10219723#1,21
>
>  --
> 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/ce682fe6-1151-49e3-857d-cb8244491b6d%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/CACczBU%2BJCM1PmrPFUrgFVXqVyOY3XCKpvKP4KSGHzRP27HmxRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Help with customizing Django authentication

2015-06-02 Thread Carlos Ribas
Hello Carl, 

I really appreciate your comments and I agree with you. I'll put here soon 
the code I'm writing, maybe this can be helpful for others too.

Thanks!

Em sexta-feira, 29 de maio de 2015 18:53:25 UTC-3, Carl Meyer escreveu:
>
> Hello Carlos, 
>
> On 05/29/2015 03:19 PM, Carlos Ribas wrote: 
> > Hello, 
> > 
> > I have to confess that I did not understand your suggestion. How this 
> > will help me to reverse the logic of my system? I mean, instead of User 
> > with or without a profile (the Person class, in my case), I want a 
> > Person with or without a User. 
> > 
> > Thanks anyway 
> > 
> > Em quarta-feira, 27 de maio de 2015 12:54:59 UTC-3, Carlos Ribas 
> escreveu: 
> > 
> > Hello All, 
> > 
> > I am currently extending the existing User model to store additional 
> > information. So, basically I have: 
> > 
> > # models.py 
> > class Person(models.Model): 
> > user = models.OneToOneField(User, verbose_name=_('User')) 
> > zipcode = models.CharField(_('Zip Code'), max_length=9, 
> > blank=True, null=True) 
> > street = models.CharField(_('Address'), max_length=255, 
> > blank=True, null=True) 
> > ... 
> > 
> > #admin.py 
> > class PersonAdmin(admin.StackedInline): 
> > model = Person 
> > ... 
> > 
> > class UserAdmin(UserAdmin): 
> > inlines = (PersonAdmin, ) 
> > ... 
> > 
> > admin.site.unregister(User) 
> > admin.site.register(User, UserAdmin)   
> > 
> > 
> > The problem is that my system should be able to register a new 
> > person, but this person may not need an account on the system (I 
> > just need to have his/her information). Right now, I can not create 
> > a person without an account. Besides that, first_name and last_name 
> > fields are not in the person class. 
> > 
> > I am wondering what is the best solution for my case. Probably, I 
> > will need to move the first_name and last_name fields to the Person 
> > class, and to do that, I will have to create custom users, is that 
> > right? 
>
> Yes, the best solution for your case (and for all Django projects) is to 
> use a custom User model. 
>
> In order to have every User linked to a Person, but not all Persons 
> linked to Users, you need to place the OneToOneField on the User model 
> pointing to Person, rather than the other way around. And in order to do 
> that, you need to have control over the User model. 
>
> (You _could_ sort of do it without a custom User model by having a 
> ManyToMany relationship between User and Person, but that allows a wide 
> variety of situations you don't want to allow.) 
>
> > If that is the case, may I just copy and paste the lines shown here 
> > (
> https://github.com/django/django/blob/master/django/contrib/auth/models.py 
> > <
> https://github.com/django/django/blob/master/django/contrib/auth/models.py>) 
>
> > and remove the lines about first_name and last_name? 
>
> No, you should follow the documentation on custom User models. 
>
> You'll want to inherit from AbstractBaseUser instead of AbstractUser, so 
> as to not have first_name and last_name fields. You'll need to add the 
> PermissionsMixin and probably a few other fields (including a username 
> field). The docs should explain what you need to know. 
>
> 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/551d6733-a4a5-48cb-acc6-e71ebd045fcf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: dhango class based views - Saving post data

2015-06-02 Thread James Schneider
Wait, what does your serializer look like? I found this in the traceback:

ile "/Users//PycharmProjects///modelserializer.py" in create

  48. return Screens.objects.create(**validated_data)

Are you sure that you are referencing the right serializer and/or is the
serializer referencing the right model? I wouldn't assume that a create()
call would be made for Screens.

-James
James,

I have commented save in model code. I have also changed the prefs field to
be char(20) for now.

I still get

'prefs' is an invalid keyword argument for this function

- Shekar



 --
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/99897c3a-1126-426c-be49-1e913ded3eeb%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/CA%2Be%2BciUJaFYSrMCq-ZQJYN2jQXXuHED%3DpVYazVtbv3YvmHvqUA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-summernote WYSIWYG editor: mixing modelForm and model, problem with Images

2015-06-02 Thread James Schneider
Have you validated that the URL being generated in the final HTML (the
source HTML in the browser) is pointing to the right location? If not, I
would tend to agree with your assertion that the media settings need
tweaking.

-James
On Jun 2, 2015 1:17 PM, "hemulin"  wrote:

> Hi,
> not sure what I've done but I don't get the error anymore, instead I got
> nothing. No error, no image in the preview and no image after the saving
> and displaying the article.
>
> To your questions, yes and yes. I can find the image in the server (under
> static/media/django-summernote/), and I can find the image
> in the DB.
>
> Interestingly, while using the "load image from URL" option in the
> summernote dialog, the url is inserted well, both in the preview and in the
> displayed article ( tag with the url src in the right place in
> form.cleaned_data['text']).
>
> Evidently the problem exists only when uploading a local image. Which
> leads me to the assumption that there is a problem with my media settings...
>
> What I have is this:
> STATIC_URL = '/static/'
> MEDIA_ROOT = os.path.join(PROJECT_PATH, "static", "media")
> MEDIA_URL = "media/"
>
> url(r'^media/(?P.*)$', 'django.views.static.serve', {
> 'document_root': settings.MEDIA_ROOT, 'show_indexes': True
> }),
>
> I can access the uploaded images via 'media/' and browsing through the
> folders, so I thought it's set up well, no I'm not so sure.
>
> Any idea what's going on here?
>
> On Tuesday, June 2, 2015 at 6:44:53 AM UTC+3, James Schneider wrote:
>>
>> Can you post the full error you're receiving? The 'blah blah blah' is
>> probably the most important. A mention of MIME types likely means that the
>> image is not uploading correctly. Can you actually find the image on the
>> server? Or a record of it in the database?
>>
>> -James
>>
>>
>>
>> On Jun 1, 2015 6:56 PM, "hemulin"  wrote:
>>
>>> (noob warning)
>>>
>>> I wanted to use summernote within a model but without using the default
>>> modelForm.
>>> I ended up mixing the two like this (can't have widgets on model
>>> field...):
>>> In models I have
>>>
>>> class Article(models.Model):
>>>  """Represents a wiki article"""
>>>  title = models.CharField(max_length=100)
>>>  slug = models.SlugField(max_length=50, unique=True)
>>>  text = models.TextField()
>>>  author = models.ForeignKey(User)
>>>  created_on = models.DateTimeField(auto_now_add=True)
>>>  objects = models.Manager()
>>>  tags = TaggableManager(through=TaggedArticle)
>>>
>>> class ArticleForm(forms.ModelForm):
>>>  class Meta:
>>>   model = Article
>>>   fields = ['text']
>>>   widgets = {
>>> 'text': SummernoteWidget(),
>>>   }
>>>
>>> After having the right display while serving the template, I attempt to
>>> save the Article like this:
>>> in views, a part of the saving method:
>>>
>>> form = ArticleForm(request.POST or None)
>>> if form.is_valid():
>>> #import pdb; pdb.set_trace()
>>> article = Article()
>>> article.text = form.cleaned_data['text'] # THIS IS MY HACKISH WAY OF 
>>> FETCHING THE CONTENT
>>> article.author = request.user
>>> article.title = request.POST['title']
>>> article.save()
>>> if request.POST.has_key('tags'): #add relevant ones
>>>   article_tags = request.POST.getlist('tags')
>>>   article_tags = [tag for tag in article_tags]
>>>   article.tags.add(*article_tags)
>>> return HttpResponse("Article saved successfully")
>>>
>>> 1) I have everything configured (MEDIA_ROOT, MEDIA_URL, summernote url
>>> as described in the setup)
>>> 2) The widget is displayed well within iframe
>>> 3) When uploading an image I get the "mime interpreted as text blah blah
>>> blah" error
>>> 4) After saving, when displaying the article, the text is displayed well
>>> with all the markup but no image is displayed
>>> 5) For every image I try to add to an article, the image appear in
>>> django-summernote//.
>>>
>>> Finally, how would you suggest me to solve the problem and having the
>>> images uploaded and displayed correctly in the resulted article text?
>>>
>>> Cheers.
>>>
>>> --
>>> 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/1d2c3458-2275-48c8-b9b8-bc9ccbcb5e57%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 

Re: new to Django having models/views/templates question

2015-06-02 Thread James Schneider
Posting the actual model code will probably help.

Your template has this:

item.customer_location.name

But you specified the issue later as this:

item.customer_location.customer

The former won't work per your summarized model definitions. The Location
model has no attribute called 'name'.

The latter will work only if your __str__() function is encoding the data
correctly. The reason you are getting a recursion error is because of the
'unicode(self)' (which I'm assuming is part of your model's __str__()
definition). You need to change that to something like unicode(self.name).
I'm not even sure if the unicode() call is even necessary (haven't done a
ton of Python 3 yet).

As far as referring to the Customer name, you can do {{
item.customer_location.customer.name }}

Have you thought about tying in the customer directly to the service order?
It shouldn't be an issue to have a customer tied to both the location and
the service order. While it'll work the way you have it, your lookups will
become more complicated (and expensive from a processing perspective) since
you are forcing a lookup across multiple tables. It may not agree with your
business process, though. Just a thought.

-James


On Jun 2, 2015 11:57 AM, "Chris Strasser"  wrote:

> Hi James thanks for the response...
>
>
> this line: {{item.customer_location.customer}}
>
> . worked this morning and all last week  now gives this error:
>
> RuntimeError at /sto/
>
> maximum recursion depth exceeded while calling a Python object
>
>  Request Method: GET  Request URL: http://10.0.0.102:8080/sto/  Django
> Version: 1.8  Exception Type: RuntimeError  Exception Value
>
>
>
>
> maximum recursion depth exceeded while calling a Python object
>
>
> I can reproduce the encoding error but i forget how to get there at the 
> moment ...
>
>
>
>
>
> On Tuesday, June 2, 2015 at 2:00:22 PM UTC-4, Chris Strasser wrote:
>>
>> Hi am plugging away at learning Django and have done well so far (thanks
>> to great documentation and Stackoverflow) but I have run into a problem
>> that i cant seem to figure out.
>>
>>
>> I have a model that refers to another model that refers to another model.
>>
>> example :
>>
>> Class ServiceOrder
>> id -integer
>>customer location = foreign key to location
>>
>> def __str__(self):
>> return self.stid
>>
>> class Location:
>>id -integer
>>address -char
>>customer- foreign key to customer
>>
>> q= '%s %s %s %s ' %(self.addr1, self.addr2, self.city,
>> self.country)
>> return unicode(q).encode('utf-8')
>>
>> Class Customer
>> id=int
>> name- char
>> return unicode(self).encode('utf-8')
>>
>> I have a template that lists the service orders view is below:
>>
>>
>> def serviceorder_list(request, status = 'Closed'):
>> ist = ServiceOrder.objects.filter(status = status,
>> stid__lte=20239).select_related('customer_location__customer')
>> #stid__lte 20239 to fix database error ... i have existing data that has
>> its own issues...
>> count = order_list.count()
>> context ={'list': sto_list, 'count': count}
>>
>> return render(request, 'order/listview.html', context)
>>
>>
>> in my listview.html
>>
>> {% for item  in list %}
>> {% if item.project %}
>> {{item.stid}}
>> {{item.project}}
>> {{item.customer_location.name}}
>> -- 2 questions here  1) it throws an error on customer
>> names that have accents etc ...
>>
>> {{item.notes}}
>> 2) i am confused about how to properly referenece the
>> customer name or anything else that is not in the Service order  model.
>>
>> {{item.person_responsible}}
>> {{item.entrydate|date:'M-d-y'}}
>>   {{item.status}}
>>   {{item.billing}}
>>   
>>
>>
>> I have read the docs many times and the more i read the more i know that
>> i don't know ... any help would be appreciated
>>
>>
>> Thanks
>>
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/bd0e074b-f45e-404b-87c7-919c2176d2dc%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@go

Re: django-summernote WYSIWYG editor: mixing modelForm and model, problem with Images

2015-06-02 Thread hemulin
I'm not sure I understood your question.
If by "final HTML" you mean the rendered template which displays the 
article, then there's nothing interesting here. I'm just passing the 
article in the context to the template and in the template assigning in 
various tags the relevant content ({% article.title %}, {% article.text %}, 
etc.)

I'm more concerned (or lets say, suspicious) that even after the image 
dialog is closed (and the upload request is being processed and returned 
'200 ok', and the file is on the server) the image is not shown in the 
summernote editor.

Does the settings looks ok to you?

On Wednesday, June 3, 2015 at 12:16:09 AM UTC+3, James Schneider wrote:
>
> Have you validated that the URL being generated in the final HTML (the 
> source HTML in the browser) is pointing to the right location? If not, I 
> would tend to agree with your assertion that the media settings need 
> tweaking.
>
> -James
> On Jun 2, 2015 1:17 PM, "hemulin" > 
> wrote:
>
>> Hi,
>> not sure what I've done but I don't get the error anymore, instead I got 
>> nothing. No error, no image in the preview and no image after the saving 
>> and displaying the article.
>>
>> To your questions, yes and yes. I can find the image in the server (under 
>> static/media/django-summernote/), and I can find the image 
>> in the DB.
>>
>> Interestingly, while using the "load image from URL" option in the 
>> summernote dialog, the url is inserted well, both in the preview and in the 
>> displayed article ( tag with the url src in the right place in 
>> form.cleaned_data['text']).
>>
>> Evidently the problem exists only when uploading a local image. Which 
>> leads me to the assumption that there is a problem with my media settings...
>>
>> What I have is this:
>> STATIC_URL = '/static/'
>> MEDIA_ROOT = os.path.join(PROJECT_PATH, "static", "media")
>> MEDIA_URL = "media/"
>>
>> url(r'^media/(?P.*)$', 'django.views.static.serve', {
>> 'document_root': settings.MEDIA_ROOT, 'show_indexes': True
>> }),
>>
>> I can access the uploaded images via 'media/' and browsing through the 
>> folders, so I thought it's set up well, no I'm not so sure.
>>
>> Any idea what's going on here?
>>
>> On Tuesday, June 2, 2015 at 6:44:53 AM UTC+3, James Schneider wrote:
>>>
>>> Can you post the full error you're receiving? The 'blah blah blah' is 
>>> probably the most important. A mention of MIME types likely means that the 
>>> image is not uploading correctly. Can you actually find the image on the 
>>> server? Or a record of it in the database?
>>>
>>> -James
>>>
>>>
>>>
>>> On Jun 1, 2015 6:56 PM, "hemulin"  wrote:
>>>
 (noob warning)

 I wanted to use summernote within a model but without using the default 
 modelForm.
 I ended up mixing the two like this (can't have widgets on model 
 field...):
 In models I have

 class Article(models.Model):
  """Represents a wiki article"""
  title = models.CharField(max_length=100)
  slug = models.SlugField(max_length=50, unique=True)
  text = models.TextField()
  author = models.ForeignKey(User)
  created_on = models.DateTimeField(auto_now_add=True)
  objects = models.Manager()
  tags = TaggableManager(through=TaggedArticle)

 class ArticleForm(forms.ModelForm):
  class Meta:
   model = Article
   fields = ['text']
   widgets = {
 'text': SummernoteWidget(),
   }

 After having the right display while serving the template, I attempt to 
 save the Article like this:
 in views, a part of the saving method:

 form = ArticleForm(request.POST or None)
 if form.is_valid():
 #import pdb; pdb.set_trace()
 article = Article()
 article.text = form.cleaned_data['text'] # THIS IS MY HACKISH WAY OF 
 FETCHING THE CONTENT
 article.author = request.user
 article.title = request.POST['title']
 article.save()
 if request.POST.has_key('tags'): #add relevant ones
   article_tags = request.POST.getlist('tags')
   article_tags = [tag for tag in article_tags]
   article.tags.add(*article_tags)
 return HttpResponse("Article saved successfully")

 1) I have everything configured (MEDIA_ROOT, MEDIA_URL, summernote url 
 as described in the setup)
 2) The widget is displayed well within iframe
 3) When uploading an image I get the "mime interpreted as text blah 
 blah blah" error
 4) After saving, when displaying the article, the text is displayed 
 well with all the markup but no image is displayed
 5) For every image I try to add to an article, the image appear in 
 django-summernote//.

 Finally, how would you suggest me to solve the problem and having the 
 images uploaded and displayed correctly in the resulted article text?

 Cheers.

 -- 
 You received this message because you are subscribed to the Google 
 Gr

how to get get-pip.py

2015-06-02 Thread Steve Burrus
how do I get get-pip.py?

 

-- 
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/74aa072c-181d-42c6-81ac-92029d305356%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: dhango class based views - Saving post data

2015-06-02 Thread Shekar Tippur
Here is my serializer

class UserPrefSerializer(serializers.ModelSerializer):
#user = serializers.ReadOnlyField(source='owner.username')
def create(self, validated_data):
print ("Validated data")
print (validated_data)
#return Screens.objects.create(**validated_data)
return Screens.objects.create(**validated_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/843711c1-1e3b-425a-a768-9f01ced89a3e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trouble w. Setting Up Virtual Env.

2015-06-02 Thread Mike Dewhirst

Steve

If you have uninstalled and reinstalled virtualenv exactly the way the 
virtualenv docs require for Windows and you still get the same problem I 
think your environment must be blocking things.


Maybe there is a virtualenv mailing list you could join and get some 
help from virtualenv experts. I use it but I installed it some time ago 
and it just works for me.


It will be well worth your time and effort to keep trying.

Good luck

Mike

On 3/06/2015 3:19 AM, Steve Burrus wrote:

*/I hasve repeatedly tried now to set up the Django Virtual Environment
without any success! Just what am I doing wrong anyway?? I am at my
"wit's end"  trying to figure out what the specific problem is./*
*//*
*/c:\Users\SteveB\Desktop>virtualenv steve1/*
*/Using base prefix 'C:\\Python 3.5'/*
*/New python executable in steve1\Scripts\python.exe/*
*/Installing setuptools, pip, wheel.../*
*/  Complete output from command
c:\Users\SteveB\Desk...1\Scripts\python.exe -c "import sys, pip;
sys...d\"] + sys.argv[1:]))" setuptools pip wheel:/*
*/  Ignoring indexes: https://pypi.python.org/simple/*
*/Collecting setuptools/*
*/  The repository located at None is not a trusted or secure host and
is being ignored. If this repository is available via HTTPS it is
recommended to use HTTPS instead, otherwise you may silence this warning
and allow it anyways with '--trusted-host None'./*
*/  The repository located at None is not a trusted or secure host and
is being ignored. If this repository is available via HTTPS it is
recommended to use HTTPS instead, otherwise you may silence this warning
and allow it anyways with '--trusted-host None'./*
*/  The repository located at None is not a trusted or secure host and
is being ignored. If this repository is available via HTTPS it is
recommended to use HTTPS instead, otherwise you may silence this warning
and allow it anyways with '--trusted-host None'./*
*/  The repository located at None is not a trusted or secure host and
is being ignored. If this repository is available via HTTPS it is
recommended to use HTTPS instead, otherwise you may silence this warning
and allow it anyways with '--trusted-host None'./*
*/  The repository located at None is not a trusted or secure host and
is being ignored. If this repository is available via HTTPS it is
recommended to use HTTPS instead, otherwise you may silence this warning
and allow it anyways with '--trusted-host None'./*
*/  The repository located at None is not a trusted or secure host and
is being ignored. If this repository is available via HTTPS it is
recommended to use HTTPS instead, otherwise you may silence this warning
and allow it anyways with '--trusted-host None'./*
*/  Could not find a version that satisfies the requirement setuptools
(from versions: )/*
*/No matching distribution found for setuptools/*
*//*
*/...Installing setuptools, pip, wheel...done./*
*/Traceback (most recent call last):/*
*/  File "C:\Python 3.5\lib\runpy.py", line 170, in _run_module_as_main
"__main__", mod_spec)/*
*/  File "C:\Python 3.5\lib\runpy.py", line 85, in _run_code exec(code,
run_globals)/*
*/  File "C:\Python 3.5\Scripts\virtualenv.exe\__main__.py", line 9, in
/*
*/  File "C:\Python 3.5\lib\site-packages\virtualenv.py", line 832, in
main symlink=options.symlink)/*
*/  File "C:\Python 3.5\lib\site-packages\virtualenv.py", line 1004, in
create_environment/*
*/install_wheel(to_install, py_executable, search_dirs)/*
*/  File "C:\Python 3.5\lib\site-packages\virtualenv.py", line 969, in
install_wheel/*
*/'PIP_NO_INDEX': '1'/*
*/  File "C:\Python 3.5\lib\site-packages\virtualenv.py", line 910, in
call_subprocess/*
*/% (cmd_desc, proc.returncode))/*
*/OSError: Command c:\Users\SteveB\Desk...1\Scripts\python.exe -c
"import sys, pip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel
failed with error code 1/*

--
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/898eb3b7-a396-40d3-8ec6-4815d48c2263%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://gr

Re: dhango class based views - Saving post data

2015-06-02 Thread Shekar Tippur
James,
You are right. I am able to get past that issue.
The next stumbling block is with 

null value in column "address_id" violates not-null constraint
DETAIL:  Failing row contains (10, Likes, null, null).

Here is my curl

curl -H  "Authorization: Bearer $usertoken" -H "Content-Type: 
application/json" -X POST -d '{"address":"XYZ","prefs":"Likes"}' 
http://${endpoint}/addPrefs


How do I pass the address name so that it gets translated to an id in the 
background.


- Shekar

-- 
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/8b031b31-3b95-43cd-bcd7-cb46b315703d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-summernote WYSIWYG editor: mixing modelForm and model, problem with Images

2015-06-02 Thread James Schneider
Sorry about that. What I meant was what do the URL's look like after the
template rendering completes (ie what does the browser see as the value for
your  tags). Since it is breaking while editing the
document, that question is now moot.

Your media settings are probably OK (however I'm smashing together paths in
my head, so I can't say for sure), but you'll need to verify that
summernote is properly generating the URL's. After uploading the photo, you
should see the 200 response for the file upload request. I then assume that
another piece of JS fires off to pull down the image that was just uploaded
so that it can be displayed in the editor. Do you immediately see another
GET request after the file upload for the image file completes? If so, does
the URL that is being requested appear correct, and if so, what is the
server response? If you are receiving a 200 response to pull down the
picture, or if you can manually copy/paste that image path in another
browser tab and pull down the picture yourself, then there is something
going on with the Summernote JS and you'll need to take that up with them.
If it is using the wrong URL, then you should check the upload settings
within Summernote (seems like there are a fair number of them), and if that
fails to bear any fruit, you'll probably need to open a request with them
on how to troubleshoot.

Given that you can see the files on the server via the browser manually,
and the uploader appears to be working correctly, I think you can narrow
down the issue to something within Summernote. I saw that you opened a
ticket on GitHub with them.

HTH,

-James



On Tue, Jun 2, 2015 at 3:41 PM, hemulin  wrote:

> I'm not sure I understood your question.
> If by "final HTML" you mean the rendered template which displays the
> article, then there's nothing interesting here. I'm just passing the
> article in the context to the template and in the template assigning in
> various tags the relevant content ({% article.title %}, {% article.text %},
> etc.)
>
> I'm more concerned (or lets say, suspicious) that even after the image
> dialog is closed (and the upload request is being processed and returned
> '200 ok', and the file is on the server) the image is not shown in the
> summernote editor.
>
> Does the settings looks ok to you?
>
> On Wednesday, June 3, 2015 at 12:16:09 AM UTC+3, James Schneider wrote:
>>
>> Have you validated that the URL being generated in the final HTML (the
>> source HTML in the browser) is pointing to the right location? If not, I
>> would tend to agree with your assertion that the media settings need
>> tweaking.
>>
>> -James
>> On Jun 2, 2015 1:17 PM, "hemulin"  wrote:
>>
>>> Hi,
>>> not sure what I've done but I don't get the error anymore, instead I got
>>> nothing. No error, no image in the preview and no image after the saving
>>> and displaying the article.
>>>
>>> To your questions, yes and yes. I can find the image in the server
>>> (under static/media/django-summernote/), and I can find the
>>> image in the DB.
>>>
>>> Interestingly, while using the "load image from URL" option in the
>>> summernote dialog, the url is inserted well, both in the preview and in the
>>> displayed article ( tag with the url src in the right place in
>>> form.cleaned_data['text']).
>>>
>>> Evidently the problem exists only when uploading a local image. Which
>>> leads me to the assumption that there is a problem with my media settings...
>>>
>>> What I have is this:
>>> STATIC_URL = '/static/'
>>> MEDIA_ROOT = os.path.join(PROJECT_PATH, "static", "media")
>>> MEDIA_URL = "media/"
>>>
>>> url(r'^media/(?P.*)$', 'django.views.static.serve', {
>>> 'document_root': settings.MEDIA_ROOT, 'show_indexes': True
>>> }),
>>>
>>> I can access the uploaded images via 'media/' and browsing through the
>>> folders, so I thought it's set up well, no I'm not so sure.
>>>
>>> Any idea what's going on here?
>>>
>>> On Tuesday, June 2, 2015 at 6:44:53 AM UTC+3, James Schneider wrote:

 Can you post the full error you're receiving? The 'blah blah blah' is
 probably the most important. A mention of MIME types likely means that the
 image is not uploading correctly. Can you actually find the image on the
 server? Or a record of it in the database?

 -James



 On Jun 1, 2015 6:56 PM, "hemulin"  wrote:

> (noob warning)
>
> I wanted to use summernote within a model but without using the
> default modelForm.
> I ended up mixing the two like this (can't have widgets on model
> field...):
> In models I have
>
> class Article(models.Model):
>  """Represents a wiki article"""
>  title = models.CharField(max_length=100)
>  slug = models.SlugField(max_length=50, unique=True)
>  text = models.TextField()
>  author = models.ForeignKey(User)
>  created_on = models.DateTimeField(auto_now_add=True)
>  objects = models.Manager()
>  tags = TaggableManager(through=Ta

Re: Update dates in models auto

2015-06-02 Thread Lachlan Musicman
Over ride the save() method on teh Actions:

class Actions(models.Model):

date_start_preview = models.DateField('Data Prevista Inicial',
blank=True)
date_end_preview = models.DateField('Data Prevista Final', blank=True)
date_start = models.DateField('Data Real Inicial', blank=True)
date_end = models.DateField('Data Real Final', blank=True)

actionplan = models.ForeignKey(Actionplan, verbose_name='Ações',
related_name='actions')

def save(self, *args, **kwargs):
   # if you want the time "now"
   self.actionplan.date_start = datetime.datetime.now()
   # OR if you want the time to be the same as in the action:
   # self.actionplan.date_start = self.date_start
   # etc etc, do same for each var
   super(Actions, self).save(*args, **kwargs)


(check syntax if you need Timezones:
https://docs.djangoproject.com/en/1.8/topics/i18n/timezones/ , and here are
the docs on method overriding:
https://docs.djangoproject.com/en/1.8/topics/db/models/#overriding-predefined-model-methods
)

cheers
L.

--
let's build quiet armies friends, let's march on their glass towers...let's
build fallen cathedrals and make impractical plans

- GYBE

On 3 June 2015 at 00:37, Juliano Araújo Farias  wrote:

> Dears,
>
> First I thx for ur attentions... and I novete in Django... but a have a
> question...
>
> Second:
> I have this in my model:
>
> class Actionplan(models.Model):
>
> date_start_preview = models.DateField('Data Prevista Inicial',
> blank=True, null=True)
> date_end_preview = models.DateField('Data Prevista Final', blank=True,
> null=True)
> date_start = models.DateField('Data Real Inicial', blank=True,
> null=True)
> date_end = models.DateField('Data Real Final', blank=True, null=True)
>
> class Actions(models.Model):
>
> date_start_preview = models.DateField('Data Prevista Inicial',
> blank=True)
> date_end_preview = models.DateField('Data Prevista Final', blank=True)
> date_start = models.DateField('Data Real Inicial', blank=True)
> date_end = models.DateField('Data Real Final', blank=True)
>
> actionplan = models.ForeignKey(Actionplan, verbose_name='Ações',
> related_name='actions')
>
>
> ---
> and I want in admin do:
>
> When the user create a action, the dates in actionplans update with the
> sum dates...
>
>
> 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/2309e9e6-8289-4ea6-865e-9095bddb9fe8%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/CAGBeqiM0Lp1xfgx9JfvAr%3DuK86LPvgTpiYXbLtgGJJUokF51_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: i have got a forbidden error in my project plz help for solve it

2015-06-02 Thread Lachlan Musicman
DHaval,

Attachments wont cut it.

Please paste the code into your email or into http://dpaste.com/

Also, a pyc file isn't a file that is readable by humans - you will need to
send the code from the py file.

You will need to also send the exact error.

Cheers
L.

--
let's build quiet armies friends, let's march on their glass towers...let's
build fallen cathedrals and make impractical plans

- GYBE

On 3 June 2015 at 03:01, DHaval Joshi  wrote:

> i try to solve forbidden error bt its not working .
> i m new  in django so plz help me to solv this error
>
> i attach
> my templet
> views.py
> and url.py
> if u need more thing then reply me i send it to u..
>
>  --
> 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/0c3193d4-afff-4376-a7c2-75fc4ecf1460%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/CAGBeqiP5jg1L6vu8U7ToCXTBW6JSwFwkzq9ZL8mjqycekn4n7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to get get-pip.py

2015-06-02 Thread Vijay Khemlani
https://pip.pypa.io/en/latest/installing.html

On Tue, Jun 2, 2015 at 7:37 PM, Steve Burrus 
wrote:

> how do I get get-pip.py?
>
>
>
> --
> 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/74aa072c-181d-42c6-81ac-92029d305356%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/CALn3ei1AXJrrHcRf4Pd-ec_o32aZLfNAh1qDVR6SLWYmedjDzQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: dhango class based views - Saving post data

2015-06-02 Thread Shekar Tippur
Here is my view. 

request.data has the 2 fields I am passing however serializer.validated_data 
has only prefs.


class AddToUserProfile(generics.CreateAPIView):
permission_classes = 
(permissions.IsAuthenticatedOrReadOnly,IsOwnerOrReadOnly)
serializer_class = UserPrefSerializer
queryset = UserPrefs.objects.all()
lookup_field = 'user_id'

#def create(self,request,*args, **kwargs):
def post(self, request, *args, **kwargs):
serializer = UserPrefSerializer(data=request.data)
print (repr(serializer))
#user=request.user
if serializer.is_valid():
print ("validated_data")
print (serializer.validated_data)  ## Here i get only prefs - 
ItemsView(OrderedDict([('prefs', 'Likes')]))
print (request.data) ## Here I see both address as well as prefs 
{'address': 'XYZ', 'prefs': 'Likes'}
serializer.create(serializer.validated_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/a9d8abf8-f393-4a1a-a08f-839046da51ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: dhango class based views - Saving post data

2015-06-02 Thread James Schneider
The 'address' field is an FK to the Address model (hence the reference to
'address_id'), and you'll either need to 1) add null=True to the address
field definition in UserPrefs and update your migrations and allow a
UserPref model to not be connected to an Address model, 2) find the right
Address model within your various create/save() method calls and include it
when creating a UserPref object, or 3) Create a new Address object, save
it, and then pass it in when creating the UserPref object.

Sounds like option 3 is the way you want to go since you are including a
string that can be used to create an Address object. That would probably be
best in your create() call so that a new Address object isn't created
whenever you update your UserPref object.

Just keep in mind that you are creating two objects in this view, one
UserPref, and an Address that gets attached to your UserPref. Simply
setting userpref.address to "XYZ" is incorrect.

-James



On Tue, Jun 2, 2015 at 5:18 PM, Shekar Tippur  wrote:

> James,
> You are right. I am able to get past that issue.
> The next stumbling block is with
>
> null value in column "address_id" violates not-null constraint
> DETAIL:  Failing row contains (10, Likes, null, null).
>
> Here is my curl
>
> curl -H  "Authorization: Bearer $usertoken" -H "Content-Type:
> application/json" -X POST -d '{"address":"XYZ","prefs":"Likes"}' http://
> ${endpoint}/addPrefs
>
>
> How do I pass the address name so that it gets translated to an id in the
> background.
>
>
> - Shekar
>
> --
> 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/8b031b31-3b95-43cd-bcd7-cb46b315703d%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/CA%2Be%2BciWNHnoggv59vKvfMVMBQP%3DfGii6FkkHrMeUyeyp9NjLRg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: dhango class based views - Saving post data

2015-06-02 Thread Shekar Tippur
James.

address table already has a record of name xyz. Request object has a address 
value of address: xyz. 

As I am initializing serialize with request.data, why is it that I don't see it 
in validated_data?
Do I need to add address_id to validated_data in my view?

-- 
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/6d31cc5b-41d2-49b4-a193-5743330914f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django session key collision

2015-06-02 Thread Greg
I've noticed a number of apparent session collisions (i.e., two or more 
users getting the same session key and therefore each others session data) 
on a site I manage. The site is on django 1.3.7, which shouldn't have any 
issues with session key collisions (there were some in earlier django 
versions) but I don't know whether it's entirely thread safe?

How would I go about debugging this? I can't reproduce the bug so at a bit 
of a loss as to how to fix it.

-- 
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/8b1e5d0d-8fe9-4a6d-87a6-2ee275c840ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: dhango class based views - Saving post data

2015-06-02 Thread James Schneider
No, it looks like you need to set a model in the Meta class as part of your
ModelSerializer class.

http://www.django-rest-framework.org/api-guide/serializers/#modelserializer

Is "XYZ" a valid slug to retrieve that Address object? You probably need to
provide the PK value for the 'address' rather than some other field,
otherwise you'll be doing some crazy overriding to pull the right Address
object.

Your submitted data dictionary is probably going to look something like
this:

{"address":"14","prefs":"0"}'

Where 14 is the PK of the Address object you want to use.

I'm a little out in the weeds here since I don't have a DRF setup of my
own, so please make sure you read through the docs.

Typically, you won't be submitting the "human readable" version of related
(foreign key) field via POST, it will almost always be a PK. The same rule
applies for any field that has a 'choices' attribute, you would submit the
key value, not the display value. In the case of 'prefs', this would be
"1", "3", etc. rather than "Likes" or "Dislikes", per your Preferences
list.

API's are made for computers to communicate with other computers, not for
people.

-James



James.

address table already has a record of name xyz. Request object has a
address value of address: xyz.

As I am initializing serialize with request.data, why is it that I don't
see it in validated_data?
Do I need to add address_id to validated_data in my view?

--
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/6d31cc5b-41d2-49b4-a193-5743330914f9%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/CA%2Be%2BciURnXSqW6kucbXcEFvqsRjK8Eem7dQD6xnPqus%2Binyk_Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: dhango class based views - Saving post data

2015-06-02 Thread Shekar Tippur
James,

I was able to get thro with the save operation. It was quite a bit of 
learning.

Meta section on the model existed but I was not populating validated_data 
properly. I was under the assumption that 

when I did

serializer=UserPrefSerializer(data=request.data)

seriazer object will be populated with post request data.

I had to resort to

 address_obj=Stock.objects.get(symbol=request.data['address'])

 user_obj=User.objects.get(username=request.user)

serializer.validated_data['stock_id']=address_obj.id

serializer.validated_data['user_id']=user_obj.id

I am not sure if this is the optimal way to do it but this seem to have 
done the trick.

Heartfelt thanks for handholding me through this.

- Shekar

-- 
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/452653a5-6bcc-4e48-9bd8-8d9aea866ecc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.