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 bi

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 sto

Re: One ->Many forms outside admin

2013-02-11 Thread Jani Tiainen
Hi, I think you're looking for (model) formsets. 11.2.2013 10:49, alexandre...@gmail.com kirjoitti: 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

change select choices in django admin on select of another field

2013-02-11 Thread vijay shanker
Hi I have a model called Place, which is like this: class Place(models.Model): state = models.CharField(max_lengh=50, choices=STATE_CHOICES) city = models.Charfield(max_length=50) I want to populate select choices for repective city for state in admin, when the user selects t

Re: Replacing a model instance's __dict__

2013-02-11 Thread Tom Evans
Thanks for the advice guys, I didn't like it much either - a Friday afternoon solution. I'll do something a little less brute force ;) Cheers Tom On Sat, Feb 9, 2013 at 11:22 AM, Bill Freeman wrote: > Tom, > > I suspect that there man be problematic, perhaps dependent on python > version, becau

A small bug for dynamic choices

2013-02-11 Thread vijay shanker
hi i wrote a function for producing tuples of all model names, which is this: from django.contrib.contenttypes.models import ContentType from django.db.models.loading import get_model def get_all_models(): return tuple([(each.__module__+'.'+each.__name__,each.__name__) for each in [each.mode

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

Re: One ->Many forms outside admin

2013-02-11 Thread Jani Tiainen
11.2.2013 13:38, alexandre...@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

django-achievements: registering achievements

2013-02-11 Thread Henri
Newbie request here - could anyone elaborate on/explain the following quote from the django-achievements documentation. I'm having a hard time wrapping my head around it.Thanks! --- To register it i

Re: Overall Design Question

2013-02-11 Thread Ajinkya Gadewar
Hi Alex, I already have a education system developed. We run a software company in India. Let me know if you need more details on it. Regards, Ajinkya Gadewar Sent from my iPhone On 11-Feb-2013, at 2:17 PM, "alexandre...@gmail.com" wrote: > Hi > I'm starting a big app on Django for Shool ma

Accessing REMOTE_USER in models/backend

2013-02-11 Thread fsang
Hi, I am developing a Django application which will be accessed by it's users both via HTTP and through the Python shell. All of my models have a "touch_user" and "create_user" attribute, containing usernames in plain text. This is primarily used for logging purposes, nothing critical. My idea

Using template fragment caching *inside* a sitewide cache: possible?

2013-02-11 Thread Matt Andrews
Hi all, I've been experimenting with an expensive query I need to call (essentially grabbing data from some Google APIs). I tried this experiment: - A sitewide cache with a long (days) expiry time - A template fragment with its own separate cache *inside* a view cached by the sitewide

Re: A small bug for dynamic choices

2013-02-11 Thread vijay shanker
I found out that ('shoppingcart.models.Cart', 'Cart') is lost coz it doesnot finds any model_class (i.e model_class is None and is thus filtered out ) when i am running the code but it does finds the model_class from python shell. something which is not very obvious is happening. On Monday, F

Question on django scrapy integration

2013-02-11 Thread kl4us
Hi all, i have a question on scrapy -> django integration. i have this models on django: from django.db import models from django.utils import timezone import datetime class Job(models.Model): title = models.CharField(max_length=100) description = models.TextField(max_length=500) url

Re: Any good books for learning django?

2013-02-11 Thread W.
Do not pirate. However. If you checked their webpage https://django.2scoops.org/ , you would see. Can't Afford the Book? > > If you're struggling with finances and can't afford it, let us know and > we'd be happy to send you a free copy. Drop us a note at and > we'll get it to you within 72

Re: Any good books for learning django?

2013-02-11 Thread frocco
That's good to know, hopefully the person asked for a free copy will head over to there. On Monday, February 11, 2013 8:52:52 AM UTC-5, W. wrote: > > Do not pirate. > However. If you checked their webpage https://django.2scoops.org/ , you > would see. > > Can't Afford the Book? >> >> If you'r

How do I get the current user in a model?

2013-02-11 Thread frocco
Hello, I have some logic I want to put in a model, but it requires know the current user logged in. Is there a way to get this? The template would have to display the results of the field returned from the model. Thanks -- You received this message because you are subscribed to the Google Gr

ContentType's model_class is NoneType

2013-02-11 Thread vijay shanker
Hi I have few models in a app called shoppingcart. I can find contenttypes associated with this model with this: >>>ct = ContentType.objects.filter(app_label='shoppingcart') >>>ct [, , , ] but when i try ct[0].model_class() it returns the model class on shell but gives me a NoneType when i try

Re: How do I get the current user in a model?

2013-02-11 Thread Sandeep kaur
On Mon, Feb 11, 2013 at 7:42 PM, frocco wrote: > Hello, > > I have some logic I want to put in a model, but it requires know the current > user logged in. > Is there a way to get this? > This gets the current logged in user : current_user = request.user -- Sandeep Kaur E-Mail: mkaurkha...@gmail

Re: How do I get the current user in a model?

2013-02-11 Thread frocco
Ok, but is request available in models.py? On Monday, February 11, 2013 9:49:47 AM UTC-5, sandy wrote: > > On Mon, Feb 11, 2013 at 7:42 PM, frocco > > wrote: > > Hello, > > > > I have some logic I want to put in a model, but it requires know the > current > > user logged in. > > Is there a

Re: IntegrityError when creating a brand new model instance

2013-02-11 Thread Bill Freeman
On Sun, Feb 10, 2013 at 10:50 AM, Some Developer wrote: > On 10/02/13 15:07, Bill Freeman wrote: > >> Did you previously have a field named 'title' in this model that was >> marked unique, that you have since removed? If so, the column may still >> be in the database with a unique constraint. Si

Re: Question on django scrapy integration

2013-02-11 Thread kl4us
is possible to Poll.objects.get(pk=1) into scrapy? Il giorno lunedì 11 febbraio 2013 14:48:51 UTC+1, kl4us ha scritto: > > Hi all, > i have a question on scrapy -> django integration. > > i have this models on django: > > from django.db import models > from django.utils import timezone > import da

Re: How do I get the current user in a model?

2013-02-11 Thread frocco
What I am trying to do, is I have four price fields in my model and need to return just one based on current user logged in. price_a price_b price_c price_d I want to always return a field named price, based on one of those fields. On Monday, February 11, 2013 9:51:47 AM UTC-5, frocco wrote: >

Re: Overall Design Question

2013-02-11 Thread Bill Freeman
On Mon, Feb 11, 2013 at 7:13 AM, Ajinkya Gadewar < ajinkya.gade...@ishareitall.com> wrote: > Hi Alex, > > I already have a education system developed. We run a software company in > India. Let me know if you need more details on it. > > Regards, > Ajinkya Gadewar > > Sent from my iPhone > > On 11-

Re: How do I get the current user in a model?

2013-02-11 Thread Brad
Sounds like you are maybe calling a user method from a template? You will probably want to create a custom tag or filter: https://docs.djangoproject.com/en/1.4/howto/custom-template-tags/ A filter would look like this: {{ my_model_item|price:request.user }} And the filter itself something like th

Re: Overall Design Question

2013-02-11 Thread Gabriel Abdalla
Hi Alex, I'm still new to Django and Python, but I have experience in other frameworks. Here is my opinion regarding your three points: *(1) An app for each role.* I think the approach of having one app for each role is the worst thing to do. In this case, you would have too much duplicated code

Re: How do I get the current user in a model?

2013-02-11 Thread Bill Freeman
On Mon, Feb 11, 2013 at 10:05 AM, frocco wrote: > What I am trying to do, is I have four price fields in my model and need > to return just one based on current user logged in. > > price_a > price_b > price_c > price_d > > I want to always return a field named price, based on one of those fields.

Re: How do I get the current user in a model?

2013-02-11 Thread frocco
Thanks Brad, I got it working. @register.filter(name='price') def price(model, user): u = UserGroup.objects.get(user_id=user.id) level = u.price_level if level == 'B': return model.price_b if level == 'C': return model.price_c if level == 'D': return mo

Re: Any good books for learning django?

2013-02-11 Thread vijay shanker
yes u right .. my bad On Friday, February 8, 2013 6:28:20 PM UTC+5:30, Tom Evans wrote: > > On Fri, Feb 8, 2013 at 10:13 AM, vijay shanker > > > wrote: > > do u have the pdf ? > > will u share it at some place (or please mail it to me > > deon...@gmail.com) > > > Please don't use this list t

Re: Any good books for learning django?

2013-02-11 Thread vijay shanker
thanks, i bought it :) On Monday, February 11, 2013 7:37:28 PM UTC+5:30, frocco wrote: > > That's good to know, hopefully the person asked for a free copy will head > over to there. > > On Monday, February 11, 2013 8:52:52 AM UTC-5, W. wrote: >> >> Do not pirate. >> However. If you checked their

One-to-many relationships in submission forms

2013-02-11 Thread Skip Montanaro
I'm trying to learn Django by implementing a bicycle serial number database. A bike is a specific model from a given manufacturer. Each frame of a given model can have multiple serial numbers at different locations on the frame. These relationships are easily captured in this simplified mode

use app_label

2013-02-11 Thread carlos
Hi I have an app called myapp within my models eg class Foo(models): fields1 = models(blabla) fields2 = models(blabla) class Meta: verbose_name = "Foo model" app_label = 'candy' db_table = 'myapp_foo' class Bar(models): fields1 = models(blabla) fields2

Updated Django by Example tutorials

2013-02-11 Thread Rainy
Hi, I've started updating Django by Example tutorials for django version 1.5 and using class-based views. I have posted 3 tutorials so far; 3 more will be added soon: http://lightbird.net/dbe2/ I hope these will prove to be useful.. please let me know of any issues / ways to improve the guide.

How do I redirect a logged in customer to https page?

2013-02-11 Thread Alagappan
Hi, In my website, I have a few http pages and a few https pages. The session cookie has been made secure=True and once a customer logs in to the site, we keep all pages as https. But if the customer manually changes the URL to http, Django's user.is_authenticated method returns False and hence