DJANGO SERVER objects lifecycle

2014-08-09 Thread alexandre...@gmail.com
Hi 

getting into web development from a C, C++ (non web).
I read and understand quite well the django framework code... but I cannot 
grasp yet the object life cycle.
I follow the WSGIHandler and BaseHandler, and seemed to me that at every 
single reuqest, the urls is imported, and in that the admin autodiscover, 
all models admins etc
Does everything is created for a request?
Is the python interpreter in NGINX + uwsgi + django launched everytime?

Can anyone give me somelight or direct me some reading on this, I really 
want to have a good grasp on everything that is happening on the execution 
model and objects lifetime.

Regards
Alexandre Rua

-- 
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/c4306784-38bd-4d0f-bef8-421439681977%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Posting, numbering and updating docs to db

2013-05-21 Thread alexandre...@gmail.com
Hi

I'm trying to post some docs to database, and have some issues associated 
that I'm not sure howto implement in django.

class DocNumber(models.Model):
tipo=models.CharField(max_length=2)
   Year=models.IntegerField()
   Number=modelsIntegerField()

class Doc(models.Model):
   Tipo = models.CharField(max_length=2)
   Year=models.IntegerField()
   Number=modelsIntegerField()
.

class DocLine(models.Model):
doc=ForeignKey(Doc)
product=ForeignKey(Product)
price=models.FloatField()
.


In my actual native app, when I save a document I've the following procedure

1.  start a transaction
2. if is a new doc get a new number from DocNumber increment that number 
(update lock this table to ensure no more docs with this number)
3. if is an update remove the old doc from stock (old lines)
4. save Doc and DocLines to DB
5. update the stock according to new lines
6. commit the transaction


I'm not able for the moment to implement this procedure in django, it seems 
to me that it should go in Doc save method, but  not sure how to get the 
number in a unique maner and update stocks accordingly?

Anyone has been trough the same problem, as this is a common pattern for me.

Kind Regards
Alexandre Rua





-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Admin list object, display fields from a fk object

2013-05-07 Thread alexandre...@gmail.com
Thank you for your answer, that i managed to achive,
what I want is to display on the admin object list of object B, display 
name_B and name_A

Anyway
Thanks
Alex


Terça-feira, 7 de Maio de 2013 13:43:59 UTC+1, Sergiy Khohlov escreveu:
>
> this  not hard : 
>
> from django.db import models
>
> # Create your models here.
>
> class A(models.Model):
>  """ model A """
>  name_a   = models.CharField(max_length=20)
>
>  def __unicode__(self):
>  return self.name_a
>
> class B(models.Model):
>  """ Model B"""
>  keyfield = models.ForeignKey('mymodel.A')
>  name_b   = models.CharField(max_length=20)
>  def __unicode__(self):
>  
>  return self.name_b
>
>
>
> serg@debian:~/project/linkmodels/modeltest$ python manage.py  shell 
> Python 2.7.3 (default, Mar  5 2013, 01:19:40) 
> Type "copyright", "credits" or "license" for more information.
>
> IPython 0.13.2 -- An enhanced Interactive Python.
> ? -> Introduction and overview of IPython's features.
> %quickref -> Quick reference.
> help  -> Python's own help system.
> object?   -> Details about 'object', use 'object??' for extra details.
>
> In [1]: from mymodel.models import A, B
>
> In [2]: A.objects.all()
> Out[2]: []
>
> In [3]: object_A = A('object_A')
>
> In [4]: A.objects.all()
> Out[4]: []
> In [5]: object_A.save()
>
>
> In [6]: object_B = B(name_b = 'object_B')
>
> In [7]: object_B.keyfield = object_A
>
> In [8]: object_B.save()
>
> In [9]: B.objects.all()
> Out[9]: []
>
> In [10]: B.objects.filter(id=1)
> Out[10]: []
>
> In [11]: B.objects.filter(id=1)[0]
> Out[11]: 
>
> In [12]: B.objects.filter(id=1)[0].name_b
> Out[12]: u'object_B'
>
> In [13]: B.objects.filter(id=1)[0].keyfield
> Out[13]: 
>
> In [14]: B.objects.filter(id=1)[0].keyfield.name_a
> Out[14]: u'object_A'
>
>
>
> Many thanks,
>
> Serge
>
>
> +380 636150445
> skype: skhohlov
>
>
> On Tue, May 7, 2013 at 11:43 AM, alexan...@gmail.com  <
> alexan...@gmail.com > wrote:
>
>> Hi
>>
>> class A(models.Model):
>>   f1=...
>>   f2=...
>>   f3=...
>>
>> class B(models.Model)
>>   f4=Foreignkey(A)
>>   f5=...
>>   f6=...
>>
>>
>> class BAdmin(admin.ModelAdmin)
>>   list_display= (f4,f4__f2,f4__f3) # this does not work
>>
>> How do I in the list display ob objects B, diaplay some fields from A 
>> linked by the foreign key.
>> this syntax works for filter in class BAdmin!
>>
>> Regards
>> Alexandre Rua
>>  
>> -- 
>> 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?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Admin list object, display fields from a fk object

2013-05-07 Thread alexandre...@gmail.com
Hi

class A(models.Model):
  f1=...
  f2=...
  f3=...

class B(models.Model)
  f4=Foreignkey(A)
  f5=...
  f6=...


class BAdmin(admin.ModelAdmin)
  list_display= (f4,f4__f2,f4__f3) # this does not work

How do I in the list display ob objects B, diaplay some fields from A 
linked by the foreign key.
this syntax works for filter in class BAdmin!

Regards
Alexandre Rua

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: One ->Many forms outside admin

2013-02-12 Thread alexandre...@gmail.com
thanks

Segunda-feira, 11 de Fevereiro de 2013 12:02:13 UTC, Jani Tiainen escreveu:
>
> 11.2.2013 13:38, alexan...@gmail.com  kirjoitti: 
> > I think taht is for editing a bunch of equal modelsat the same time... 
> > 
> > I need to edit a 1-many relationship in the same manner admin does. 
> > 
> > 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...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users?hl=en. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
> Inline formsets to be exact is something that you're looking for: 
>
>
> https://docs.djangoproject.com/en/1.4/topics/forms/modelforms/#inline-formsets
>  
>
> -- 
> Jani Tiainen 
>
> - Well planned is half done and a half done has been sufficient before... 
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: One ->Many forms outside admin

2013-02-11 Thread alexandre...@gmail.com
I think taht is for editing a bunch of equal modelsat the same time...

I need to edit a 1-many relationship in the same manner admin does.

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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




One ->Many forms outside admin

2013-02-11 Thread alexandre...@gmail.com
Hi

I need to edit  

1->many
  ->many  forms on my pages like in admin, using inlines, but outside admin

can anyone give clues on how to do it

Regards
Alex

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Overall Design Question

2013-02-11 Thread alexandre...@gmail.com
Hi
I'm starting a big app on Django for Shool management, to replace a Win32 
app.

I've roles like teachers, students, admin stuff, ... that have diferent 
access.
How should it be developded?

1- an app for each role?
2- some logic in templates?
3- any other

what is the correct aporach to get big and simple.

Regards
Alex

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Multi Database + Huge lookups

2012-11-20 Thread alexandre...@gmail.com
Thanks

I will follow directions

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/UzXu0Wzm4W0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Multi Database + Huge lookups

2012-11-19 Thread alexandre...@gmail.com
Hi
I've a big project implemented in Delphi/C++/MSSQL that I want to migrate 
to the WEB and Python/Django is my choice.
But I'm getting some dificulties probably due to the backgroud I came from.

1-
I've have several databases One of them is for static tables like zipcodes 
Districts countrys, and a lot more stuff they rarely change, the others are 
one per enterprise/domain, taht all share common data on the statis one.
Is this solution implementable under django?


2- 
I've huge tables like ZIP codes milions or records how to do a foreign key 
that is not in a select but in an autocomplete. (is this django builtin)?


3-
Several times I've lookups where I copy more info than the key, for exemple 
in an invoice I copy the ClientID, but also the adress do the invoice, so 
if the adress changes in a future the invoice is imutable...


I would appreciate help to Kickstart me

Regards
Alexandre Rua

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/_MtW7peYBe0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Could not decode to UTF-8 column 'cpostal'

2011-06-12 Thread alexandre...@gmail.com
Hi,

I just converted a mssql database to sqlite3.
I used the folloing text_factory

con.text_factory = lambda x: x.decode('iso-8859-1').encode('utf-8')

that just converts from latin1 to utf-8
where i browse the tables in python shell it seems everything is fine
and well converted
but when in admin, I just get the error
"could not decode utf-8 column"

the columns django complains has the following data '4760 Vila Nova de
Famalic\xc3\xa3o   '

Any help appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Model field vs Form field vs Widget

2009-09-03 Thread alexandre...@gmail.com

Hi, I'm a newbie on Django and would like a reference reading on model
fields, form fields and widgets.

For example I want to have a model field called CountryField that
automatically in forms displays as a bombobox with country options.

Furthermore, I want to develop a Zip Code field like the country field
with one difference the table of Zip Codes has over a million records
so I want do develop a widget that popus another form that let me
search over that huge amount of records and fills back do the field.


I just want to create model classes with special fields, and they know
how to display themselves in forms.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---