Re: how to saven models dynamically inputted by user in form

2014-07-01 Thread Aashita Dutta


here is my model-
from django.db import models
import useraccounts
from librehatti.catalog.models import *
from django.contrib.auth.models import User

class QuotedOrder(models.Model):
quote_buyer_id = models.ForeignKey(User)
quote_is_debit = models.BooleanField()
quote_delivery_address = models.ForeignKey('useraccounts.Address')
quote_organisation = 
models.ForeignKey('useraccounts.AdminOrganisations')
quote_date_time = models.DateTimeField(auto_now_add=True)
def __unicode__(self):
return '%s' % (self.quote_buyer_id) +' - ' '%s' % 
(self.quote_date_time.strftime ('%b %d, %Y'))

class QuotedItem(models.Model):
quote_order = models.ForeignKey(PurchaseOrder)
quote_price = models.IntegerField()
quote_qty = models.IntegerField()
quote_discount= models.IntegerField()
quote_item = models.ForeignKey(Product)
status = models.IntegerField(default=0)
def save(self):
if not self.id:
self.quote_price = self.quote_item.price * self.quote_qty
super(QuotedItem,self).save()

def __unicode__(self):
return '%s' % (self.quote_item) + ' - ' '%s' % (self.quote_order)




here is my forms.py-
from django import forms
from librehatti.bills.models import *

#class ConfirmForm(forms.Form):
#quote_item = forms.CharField()
#quote_qty = forms.IntegerField()


class ConfirmForm(ModelForm):
 class Meta:
 model = QuotedItem
 fields = ('quote_item', 'quote_qty')


here is my html-file-


display items



CONFIRM ITEMS
 {% csrf_token %}


Item
Quantity


 {% for i in quoted_item %}
  

 
Item:  
Quantity:
   
   
 
  
   {% endfor %} 
   
 






here is catalog models, where i want to save the values, input by user in 
form-

from django.db import models
from django.forms import ModelForm
import useraccounts
from django.contrib.auth.models import User

class Category(models.Model):
name = models.CharField(max_length=100)
parent = models.ForeignKey('self', blank=True, null=True)
def __unicode__(self):
return unicode(self.name)


class Product(models.Model):
name = models.CharField(max_length=100)
category = models.ForeignKey(Category)
price = models.IntegerField()
organisation = models.ForeignKey('useraccounts.AdminOrganisations')
def __unicode__(self):
return self.name


class Attributes(models.Model):
name = models.CharField(max_length=200)
is_number = models.BooleanField()
is_string = models.BooleanField()
def __unicode__(self):
return self.name


class PurchaseOrder(models.Model):
buyer_id = models.ForeignKey(User)
is_debit = models.BooleanField()
delivery_address = models.ForeignKey('useraccounts.Address')
organisation = models.ForeignKey('useraccounts.AdminOrganisations')
date_time = models.DateTimeField(auto_now_add=True)
def __unicode__(self):
return '%s' % (self.buyer_id) +' - ' '%s' % (self.date_time.strftime
   ('%b %d, %Y'))


class PurchasedItem(models.Model):
purchase_order = models.ForeignKey(PurchaseOrder)
price = models.IntegerField()
qty = models.IntegerField()
discount= models.IntegerField()
item = models.ForeignKey(Product)

def save(self):
if not self.id:
self.price = self.item.price * self.qty
super(PurchasedItem,self).save()

def __unicode__(self):
return '%s' % (self.item) + ' - ' '%s' % (self.purchase_order)


class Catalog(models.Model):
attribute = models.ForeignKey(Attributes)
value = models.CharField(max_length=200)
product = models.ForeignKey(Product)
def __unicode__(self):
return self.attribute.name;


how to save now? and to generate bills also?

here is bill.html-











bill
  





 
{{quoted_order.quote_organisation.organisation_type}}
{{quoted_order.quote_organisation.tagline}}   
{{quoted_order.quote_organisation.title}}
  
{{quoted_order.quote_organisation.address}} 
Website : {{quoted_order.quoted_organisation.quote_url}}
 Email:{{quoted_order.quoted_organisation.quote_email1}}  Ph 
: 
{{quoted_order.quote_organisation.telephone}} 
 Fax : {{quoted_order.quote_organisation.fax}}
  
 Bill



STC No. {{ STC_NO }}
PAN No. {{ PAN_No. }}



No. : GNDEC/TCC/B/{{ job_no }}

Dated : {{quoted_order.date_time}} 




 To,
 {{quote_delivery_address}}
 Organisation:{{quote_organisation}}
 Buyer Id : {{ purchased_order.buyer_id.username }}
 Ref: Your Letter No.{{L_No.}}, 
dated:{{quoted_order.date_time}} , respectively.
 







  S.no.
  Charges For Following
  Price
  Per
  Total



{% if QuotedItem %}
{% for i in QuotedItem %}

 
  {{ forloop.counter }}
  {{ i.quote_item }}
  {{ i.quote_price }} 
  {{ i.quote_qty  }} 
  {{ i.total }}


{% endfor %}
{% endif %}


Total 

 {{total_cost}}
 


{% if bill.trans_total != None %}

 Transportation 

Re: Creating subusers

2014-07-01 Thread Lachlan Musicman
I would recommend Intermediate Models as a good solution for these
type of weird situations

https://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships

Cheers
L.

On 2 July 2014 12:20, Jorge Andrés Vergara Ebratt  wrote:
> Hello everyone,
>
> I'm trying to create a system that has 3 different user types:
>
> Independent Agent, that basically is what it sounds like, and Django's User
> Model works fine for this one.
>
> But the catch comes from the other 2, because it also needs to support
> agencies and agencies have sub-users...
>
> I'm trying to figure out the best way to do this, currently I'm trying with
> User profiles but don't really know if what I'm doing is correct, I'm doing
> this:
>
>
> class IndependentAgent(models.Model):
> user = models.OneToOneField(User)
> tipo_licencia = models.CharField(max_lenght=140)
>
>
> class AgencyUser(models.Model):
> user = models.OneToOneField(User)
> agency = models.ForeignKey(User, related_name='Agency')
>
>
> Can I do this? Like that user profile for Agency User would let me 'asign'
> those users to their respective agencies so that later I can set my code
> that those users can only see that agency's information?
>
> Or would making groups be better to handle this kind of situations?
>
> Appreciate any help I can get, thanks in advance
>
>
> --
> Jorge Andres Vergara Ebratt
> #SoftwareDeveloper (Or at least trying to be)
> @javebratt
> facebook.com/javebratt
>
> --
> 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/CAAeX05Gc6gnjdDi%3Dv%2B-n72mSi1JWdO1ecYUQORogvMifAw5o7w%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



-- 
The idea is that a beautiful image is frameable. Everything you need
to see is there: It’s everything you want, and it’s very pleasing
because there’s no extra information that you don’t get to see.
Everything’s in a nice package for you. But sublime art is
unframeable: It’s an image or idea that implies that there’s a bigger
image or idea that you can’t see: You’re only getting to look at a
fraction of it, and in that way it’s both beautiful and scary, because
it’s reminding you that there’s more that you don’t have access to.
It’s now sort of left the piece itself and it’s become your own
invention, so it’s personal as well as being scary as well as being
beautiful, which is what I really like about art like that.
---
Adventure Time http://theholenearthecenteroftheworld.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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/CAGBeqiPXRxw7t6qMdPNH_ECGwnK8DZrP7S1-5uzsoC3%2BtsNq5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating subusers

2014-07-01 Thread Mario Gudelj
Hey Jorge,

I think you should extend the Abstract User instead of doing it the old
way, which is creating that OneToOne relationship with a custom model. So,
you'll end up with this:

class IndependentAgent(AbstractBaseUser, PermissionsMixin):
tipo_licencia = models.CharField(max_lenght=140)

class AgencyUser(AbstractBaseUser, PermissionsMixin):
agency = models.ForeignKey(User, related_name='Agency')

This way you'll inherit all those awesome methods like setting the password
etc. and attributes, like is_admin, but you can also simply add your own
and dealing with this is much easier, than having to get the profile etc.

Cheers,

M



On 2 July 2014 12:20, Jorge Andrés Vergara Ebratt 
wrote:

> Hello everyone,
>
> I'm trying to create a system that has 3 different user types:
>
> Independent Agent, that basically is what it sounds like, and Django's
> User Model works fine for this one.
>
> But the catch comes from the other 2, because it also needs to support
> agencies and agencies have sub-users...
>
> I'm trying to figure out the best way to do this, currently I'm trying
> with User profiles but don't really know if what I'm doing is correct, I'm
> doing this:
>
>
> class IndependentAgent(models.Model):
> user = models.OneToOneField(User)
> tipo_licencia = models.CharField(max_lenght=140)
>
>
> class AgencyUser(models.Model):
> user = models.OneToOneField(User)
> agency = models.ForeignKey(User, related_name='Agency')
>
>
> Can I do this? Like that user profile for Agency User would let me 'asign'
> those users to their respective agencies so that later I can set my code
> that those users can only see that agency's information?
>
> Or would making groups be better to handle this kind of situations?
>
> Appreciate any help I can get, thanks in advance
>
>
> --
> *Jorge Andres Vergara Ebratt*
> *#SoftwareDeveloper (Or at least trying to be)*
> *@javebratt*
> *facebook.com/javebratt *
>
> --
> 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/CAAeX05Gc6gnjdDi%3Dv%2B-n72mSi1JWdO1ecYUQORogvMifAw5o7w%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/CAHqTbjmarOEX%2BJCPkTqyZq7YavkbdjQkmUPhjFeQS%3D5Ecetccg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Creating subusers

2014-07-01 Thread Jorge Andrés Vergara Ebratt
Hello everyone,

I'm trying to create a system that has 3 different user types:

Independent Agent, that basically is what it sounds like, and Django's User
Model works fine for this one.

But the catch comes from the other 2, because it also needs to support
agencies and agencies have sub-users...

I'm trying to figure out the best way to do this, currently I'm trying with
User profiles but don't really know if what I'm doing is correct, I'm doing
this:


class IndependentAgent(models.Model):
user = models.OneToOneField(User)
tipo_licencia = models.CharField(max_lenght=140)


class AgencyUser(models.Model):
user = models.OneToOneField(User)
agency = models.ForeignKey(User, related_name='Agency')


Can I do this? Like that user profile for Agency User would let me 'asign'
those users to their respective agencies so that later I can set my code
that those users can only see that agency's information?

Or would making groups be better to handle this kind of situations?

Appreciate any help I can get, thanks in advance


-- 
*Jorge Andres Vergara Ebratt*
*#SoftwareDeveloper (Or at least trying to be)*
*@javebratt*
*facebook.com/javebratt *

-- 
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/CAAeX05Gc6gnjdDi%3Dv%2B-n72mSi1JWdO1ecYUQORogvMifAw5o7w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to saven models dynamically inputted by user in form

2014-07-01 Thread Lachlan Musicman
Woah there.

Ok, well it's hard to help without more info, but here are some tips:

 - please don't ask a community project to "reply soon". We will reply
when and if we can. Obviously ideally we would reply, and speedily,
but we get what we got.

 - How to save the ForeignKey on an item? Well assign it. FYI, it's
incredibly difficult to help without some code to look at. HAving said
that, the Django documentation is *excellent* and you should utilise
it - like I said in my original emails, ModelFormsets are your friend,
you should look into them.

 - With errors, sending them raw is not a way to get them solved. They
way I solve errors like that is to Google the error, and then look at
the line of code indicated:
"EOL while scanning string literal (views.py, line 31)" <- views, line
31. Maybe line 30, probably line 31. If Google doesn't help, and you
do need to ask here (which may well be the case), you MUST include
line 31 (pref the lines 25-35) so we have an idea of what is going on.

 - The error "The view librehatti.bills.views.final didn't return an
HttpResponse object. It returned None instea" means your return
statement in the view final isn't sending a proper object back -
either change the return statement, or figure out why it's sending
None. Again, without any context at all, it's very hard to help you.



cheers
L.


On 2 July 2014 06:16, Aashita Dutta  wrote:
>
>
> On Tuesday, July 1, 2014 5:58:59 PM UTC+5:30, Lachlan Musicman wrote:
>>
>> Hi Aashita,
>>
>> There's a couple of things happening here. I'm no expert and this is a
>> rushed end of evening email.
>>
>> For getting the obj.save() to work, here:
>>
>> cd = form.cleaned_data
>> newPI = PurchasedItem()
>> newPI.name = cd['quote_item']
>> newPI.qty = cd['quote_qty']
>> newPI.save()
>>
>> You now have a new PurchaseItem with a name and a qty.
>>
>> Having said that, is there a reason you aren't using ModelForms and
>> Generic Views?
>>
>> Then there's the PurchaseOrder.  Will there be other PuchaseItems on
>> the order? Is it ManyToMany?
>>
>> If it is, it might be better to have the PurchaseOrder Form, with
>> PurchaseItem as an attached ModelFormset - in that way you can have as
>> many PIs on you PO as you want.
>>
>>
>
> now new error is coming-
>
> The view librehatti.bills.views.final didn't return an HttpResponse object.
> It returned None instea
>
> --
> 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/aa9f7896-e19a-46f5-ae5f-830a0484106e%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 
The idea is that a beautiful image is frameable. Everything you need
to see is there: It’s everything you want, and it’s very pleasing
because there’s no extra information that you don’t get to see.
Everything’s in a nice package for you. But sublime art is
unframeable: It’s an image or idea that implies that there’s a bigger
image or idea that you can’t see: You’re only getting to look at a
fraction of it, and in that way it’s both beautiful and scary, because
it’s reminding you that there’s more that you don’t have access to.
It’s now sort of left the piece itself and it’s become your own
invention, so it’s personal as well as being scary as well as being
beautiful, which is what I really like about art like that.
---
Adventure Time http://theholenearthecenteroftheworld.com/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+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/CAGBeqiO58hZecxUcYPCeb2usx%2B7_DpAPt-tCqYAD8ppb2qi9tQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


is there any way to set a default formating for float/decimal numbers like default formats for date/datetime values?

2014-07-01 Thread Juan Jose Huelga
I would like to set a float or decimal format like those set in 
django.conf.locale.en.formats, for example a default format that 
floatformat template filter could use to format my numbers by default 
without decimal places. Something like settings.USE_THOUSAND_SEPARATOR that 
django use by default when shows a number.

Greetings

-- 
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/5f83ea2e-44fb-4b68-a242-ec4f435bc157%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to saven models dynamically inputted by user in form

2014-07-01 Thread Aashita Dutta


On Tuesday, July 1, 2014 5:58:59 PM UTC+5:30, Lachlan Musicman wrote:
>
> Hi Aashita, 
>
> There's a couple of things happening here. I'm no expert and this is a 
> rushed end of evening email. 
>
> For getting the obj.save() to work, here: 
>
> cd = form.cleaned_data 
> newPI = PurchasedItem() 
> newPI.name = cd['quote_item'] 
> newPI.qty = cd['quote_qty'] 
> newPI.save() 
>
> You now have a new PurchaseItem with a name and a qty. 
>
> Having said that, is there a reason you aren't using ModelForms and 
> Generic Views? 
>
> Then there's the PurchaseOrder.  Will there be other PuchaseItems on 
> the order? Is it ManyToMany? 
>
> If it is, it might be better to have the PurchaseOrder Form, with 
> PurchaseItem as an attached ModelFormset - in that way you can have as 
> many PIs on you PO as you want. 
>
>
>
now new error is coming-

The view librehatti.bills.views.final didn't return an HttpResponse object. It 
returned None instea

-- 
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/aa9f7896-e19a-46f5-ae5f-830a0484106e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to saven models dynamically inputted by user in form

2014-07-01 Thread Aashita Dutta


On Tuesday, July 1, 2014 5:58:59 PM UTC+5:30, Lachlan Musicman wrote:
>
> Hi Aashita, 
>
> There's a couple of things happening here. I'm no expert and this is a 
> rushed end of evening email. 
>
> For getting the obj.save() to work, here: 
>
> cd = form.cleaned_data 
> newPI = PurchasedItem() 
> newPI.name = cd['quote_item'] 
> newPI.qty = cd['quote_qty'] 
> newPI.save() 
>
> You now have a new PurchaseItem with a name and a qty. 
>
Now error is coming , 

EOL while scanning string literal (views.py, line 31)

 

>
>
>

-- 
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/72276496-1d32-4c8e-a9ea-dc809fe9d454%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to saven models dynamically inputted by user in form

2014-07-01 Thread Aashita Dutta


PurchaseOrder has no use here, and yes item is foreign key to Product class 
which consists of item's name i.e item__name. Actually my QuotedItem class 
in models consist of 5 fields, and i want to save only two. Would this 
method be work? And also can we save method item__name which is foreign key?
reply soon

-- 
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/ffd63b1f-9ba6-41be-b462-73245531237a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: page not found errors for most urls but main landing page displaying okay

2014-07-01 Thread Lee
Thank you everyone. I solved the problem. It was a relative vs absolute url 
issue. There was a line in the static/js/applications.js file that had to 
be changed:
RELATIVE_URL = '/myproject';  //for development leave this blank. For 
production it should be '/myproject'

This was hard to debug because I'm doing this on a shared host and don't 
have access to the Apache logs - it was hard to figure out where the URLs 
were going. Also this is a project developed by someone else so I did not 
know about this setting in the js.

L

On Thursday, June 26, 2014 10:35:03 AM UTC-4, Vijay Khemlani wrote:
>
> Is it possible that the app is getting confused because it is not running 
> at the root of the domain (/) but instead on a subdirectory (/project/)?
>
>
> On Wed, Jun 25, 2014 at 11:51 PM, Kelvin Wong  > wrote:
>
>> If you have access to your logs, check your logs to figure out where 
>> those requests are going.
>>
>> You can also SSH into the server and temporarily turn on the DEBUG=True, 
>> TEMPLATE_DEBUG=True and let Django tell you what is going on.
>>
>> Without seeing your fcgi script, my guess is that it is Apache not 
>> mapping the request to your WSGI file/fcgi script. Double check your 
>> htaccess file mod_rewrite directives.
>>
>> K
>>
>>
>>
>> On Wednesday, June 25, 2014 2:53:21 PM UTC-7, Lee wrote:
>>>
>>> Thanks - it must be a problem with the site accessing templates but I 
>>> can't figure it out. This django project works on another server but I have 
>>> copied it to a shared host webserver  (Bluehost) and am running it with 
>>> fcgi so maybe the problem is in the setup.
>>>
>>> I am focusing on one url and template, but all have the same problem 
>>> except the main landing page, which does work.
>>>
>>> The url http://mysite/project/map/nav/ shows the right text without any 
>>> styling
>>> This is the url pattern for this page in urls.py.
>>> url(r'^map/nav/$', 'citi_digits.views.mapNavigation', name='mav_nav'),
>>>
>>> The view for this url references the template:
>>> def mapNavigation(request):
>>> """
>>> Loads the map navigation elements
>>> """
>>> #get all classes
>>> #get classes
>>> classes = Teacher.objects.values_list('className', flat=True)
>>> return render_to_response('map_navigation.html',{'classes':
>>> classes},context_instance=RequestContext(request))
>>>
>>> In the settings.py the setting for templates is:
>>> TEMPLATE_DIRS = (
>>> os.path.join(PROJECT_ROOT, '..', 'citi_digits','templates'),
>>>
>>> I also tried an absolute path and put the templates in www but this did 
>>> not work.
>>>
>>> My static settings are:
>>>
>>> STATIC_ROOT = '/home5/user/public_html/project/static/'
>>> STATIC_URL = 'http://mysite.org/project/static/'
>>>
>>> Lee
>>>
>>>
>>>
>>> On Wednesday, June 25, 2014 3:36:52 PM UTC-4, Michael Lind Hjulskov 
>>> wrote:

 Hi

 I had the exact same problem a few days ago. It was one of my templates 
 that suddenntly was emty. very spooky
 Or maybe you have an "extends" somewhere that is not correct
 I would debug by looking in the relevant view and see which template is 
 called, and the simplify that template to test if bug is in templates or 
 elsewhere

 Michael

 Den onsdag den 25. juni 2014 21.08.35 UTC+2 skrev Lee:
>
> I have copied a Django project to my web server from a repo and am 
> getting the correct initial landing page for the website with the right 
> styling when I go to the main URL. Most other urls give "page not found" 
> errors. This includes the divs that are called on to make menus on the 
> main 
> page so the "Page not found" error is printing over the main landing 
> page. 
>
> I'm not sure where to start with diagnosis - any thoughts would be 
> appreciated.
>
> I have checked the urls.py file and have tried to go directly to the 
> URLs listed starting with http://mysite.org/project/ ...
>
> urlpatterns = patterns('',
> # index.html gives a page not found error
>  url(r'^$', 'project.views.index', name='index'),
>
>
> # These go to an unstyled page with correct text
> url(r'^signup/$', 'project.views.signUp', name='signup'),
> url(r'^login/$', 'project.views.login', name='login'),
> url(r'^logout/$', 'project.views.logout', name='logout'),
>
>
> # These also give a page not found error
>
> url(r'^$', 'project.views.index', name='index'),
> url(r'^map/nav/$', 'project.views.mapNavigation', name='mav_nav'),
> url(r'^interview/new/$', 'project.views.interviewSelect', 
> name='interview_select'),
> url(r'^interview/player/$', 'project.views.interviewPlayer', 
> name='interview_player'),
> url(r'^interview/retailer/$', 'project.views.interviewRetailer', 
> name='interview_retailer'),
> url(r'^popup/(?P.+)/(?P.+)/(?P.
> +)/(?P.+)/(?P.+)/(?P.+)/(?P.+)/(?P<
> 

Re: pre_save on password

2014-07-01 Thread Avraham Serour
you should only store the user password once, if you are trying to catch it
just to register in another application then you now have two problems

you should set django use the other system as authentication backend, new
users should just register there and change their passwords there, on the
central application responsible for the users, I made some applications
django using this to rely on the company LDAP (active directory)
the users have the same login for all the applications in the company, the
ERP, windows logon, my django web apps, email etc
and you don't need to worry about storing passwords etc

or you can do it the other way around, tell the other application to
authenticate against your django users

good luck


On Tue, Jul 1, 2014 at 4:42 PM, Tom Evans  wrote:

> On Tue, Jul 1, 2014 at 1:27 PM, guillaume 
> wrote:
> > Hi Tom,
> >
> > Yes indeed, I know that page, but there is no way I can make it the same
> > than the other one which relies on SHA256, some system key I don't know
> and
> > a random salt. So there is no way for me to find the correct encryption
> for
> > the remote database, that's why I want to use it's API registration
> system
> > and feed it with the clear password.
>
>
> You first post said you wanted to intercept the plain text password so
> that you could supply it to a separate third party system that would
> generate the hash.
>
> This is what the hashing classes do. There are two functions you need
> to implement:
>
> encode(self, password, salt)
>
> This function is given the plain text password and the salt, and
> should return the encoded password for storage.
> You can call your 3rd party system with those values in order to get
> the encoded password.
>
> verify(self, password, encoded)
>
> This function is given the encoded password from the database, and the
> plain text password as supplied by the user at login, and should
> return whether the two are a match.
> Again, this can call your 3rd party system in order to effect the
> verification.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFHbX1JBiyVYjtFxQ6HZCP4e52E8MPDvCYg4w8msq3BYMuJDhw%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/CAFWa6tLNiC%3Djv7ZLdLZ%2Bc_6Qi6epHzRDr3Aaznxndp-t84VHsg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: pre_save on password

2014-07-01 Thread Tom Evans
On Tue, Jul 1, 2014 at 1:27 PM, guillaume  wrote:
> Hi Tom,
>
> Yes indeed, I know that page, but there is no way I can make it the same
> than the other one which relies on SHA256, some system key I don't know and
> a random salt. So there is no way for me to find the correct encryption for
> the remote database, that's why I want to use it's API registration system
> and feed it with the clear password.


You first post said you wanted to intercept the plain text password so
that you could supply it to a separate third party system that would
generate the hash.

This is what the hashing classes do. There are two functions you need
to implement:

encode(self, password, salt)

This function is given the plain text password and the salt, and
should return the encoded password for storage.
You can call your 3rd party system with those values in order to get
the encoded password.

verify(self, password, encoded)

This function is given the encoded password from the database, and the
plain text password as supplied by the user at login, and should
return whether the two are a match.
Again, this can call your 3rd party system in order to effect the verification.

Cheers

Tom

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


Re: pre_save on password

2014-07-01 Thread guillaume
Hi Phil,

Actually not at the hasher level, because I need to know the user's details 
as well, but it's a good hint. I should try to subclass to User Model 
set_password method. 

Thanks !

Guillaume

Le mardi 1 juillet 2014 15:03:58 UTC+2, Philip a écrit :
>
>  If the username/whatever is available within the hasher you could create 
> a subclass of the hasher you're using in Django and intercept the 
> plain-text password there, call your API and then call the superclass?
>
> Phil
>
> On 01/07/2014 13:27, guillaume wrote:
>  
> Hi Tom,
>
> Yes indeed, I know that page, but there is no way I can make it the same 
> than the other one which relies on SHA256, some system key I don't know and 
> a random salt. So there is no way for me to find the correct encryption for 
> the remote database, that's why I want to use it's API registration system 
> and feed it with the clear password. 
>
> Best regards
>
> Guillaume
>
> Le mardi 1 juillet 2014 14:17:28 UTC+2, Tom Evans a écrit : 
>>
>> On Tue, Jul 1, 2014 at 1:12 PM, guillaume  
>> wrote: 
>> > 
>> > Hi, 
>> > thanks for your reply. Actually I don't want to store the uncrypted 
>> > password, just submit it to another app registration system, which will 
>> hash 
>> > it then. The two hashing systems are too different and complicated for 
>> me to 
>> > use the django encrypted password in the other application database. 
>> > 
>>
>> How Django hashes passwords is fully configurable, see: 
>>
>> https://docs.djangoproject.com/en/1.6/topics/auth/passwords/ 
>>
>> The setting PASSWORD_HASHERS contains a list of classes that hash 
>> passwords. Simply replace this with your custom hash algorithm, or 
>> calls to your external API that implements your hash algorithm. 
>>
>> Cheers 
>>
>> Tom 
>>
>  -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users...@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/a7b49845-b8df-4897-b653-17020f339794%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/d8a78f4b-1f4d-4307-ac7a-b7704690c557%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: pre_save on password

2014-07-01 Thread Philip Mountifield
If the username/whatever is available within the hasher you could create 
a subclass of the hasher you're using in Django and intercept the 
plain-text password there, call your API and then call the superclass?


Phil

On 01/07/2014 13:27, guillaume wrote:

Hi Tom,

Yes indeed, I know that page, but there is no way I can make it the 
same than the other one which relies on SHA256, some system key I 
don't know and a random salt. So there is no way for me to find the 
correct encryption for the remote database, that's why I want to use 
it's API registration system and feed it with the clear password.


Best regards

Guillaume

Le mardi 1 juillet 2014 14:17:28 UTC+2, Tom Evans a écrit :

On Tue, Jul 1, 2014 at 1:12 PM, guillaume  wrote:
>
> Hi,
> thanks for your reply. Actually I don't want to store the uncrypted
> password, just submit it to another app registration system,
which will hash
> it then. The two hashing systems are too different and
complicated for me to
> use the django encrypted password in the other application
database.
>

How Django hashes passwords is fully configurable, see:

https://docs.djangoproject.com/en/1.6/topics/auth/passwords/


The setting PASSWORD_HASHERS contains a list of classes that hash
passwords. Simply replace this with your custom hash algorithm, or
calls to your external API that implements your hash algorithm.

Cheers

Tom

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

Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a7b49845-b8df-4897-b653-17020f339794%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/53B2B19F.1030704%40formac.net.
For more options, visit https://groups.google.com/d/optout.


Re: pre_save on password

2014-07-01 Thread guillaume
Hi Tom,

Yes indeed, I know that page, but there is no way I can make it the same 
than the other one which relies on SHA256, some system key I don't know and 
a random salt. So there is no way for me to find the correct encryption for 
the remote database, that's why I want to use it's API registration system 
and feed it with the clear password. 

Best regards

Guillaume

Le mardi 1 juillet 2014 14:17:28 UTC+2, Tom Evans a écrit :
>
> On Tue, Jul 1, 2014 at 1:12 PM, guillaume  > wrote: 
> > 
> > Hi, 
> > thanks for your reply. Actually I don't want to store the uncrypted 
> > password, just submit it to another app registration system, which will 
> hash 
> > it then. The two hashing systems are too different and complicated for 
> me to 
> > use the django encrypted password in the other application database. 
> > 
>
> How Django hashes passwords is fully configurable, see: 
>
> https://docs.djangoproject.com/en/1.6/topics/auth/passwords/ 
>
> The setting PASSWORD_HASHERS contains a list of classes that hash 
> passwords. Simply replace this with your custom hash algorithm, or 
> calls to your external API that implements your hash algorithm. 
>
> Cheers 
>
> Tom 
>

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


Re: pre_save on password

2014-07-01 Thread Tom Evans
On Tue, Jul 1, 2014 at 1:12 PM, guillaume  wrote:
>
> Hi,
> thanks for your reply. Actually I don't want to store the uncrypted
> password, just submit it to another app registration system, which will hash
> it then. The two hashing systems are too different and complicated for me to
> use the django encrypted password in the other application database.
>

How Django hashes passwords is fully configurable, see:

https://docs.djangoproject.com/en/1.6/topics/auth/passwords/

The setting PASSWORD_HASHERS contains a list of classes that hash
passwords. Simply replace this with your custom hash algorithm, or
calls to your external API that implements your hash algorithm.

Cheers

Tom

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


Re: pre_save on password

2014-07-01 Thread guillaume

Hi,
thanks for your reply. Actually I don't want to store the uncrypted 
password, just submit it to another app registration system, which will 
hash it then. The two hashing systems are too different and complicated for 
me to use the django encrypted password in the other application database. 

-- 
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/a8d981e1-addb-45dd-99ec-ee3aa6b422da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: pre_save on password

2014-07-01 Thread Rafael E. Ferrero
Sorry... i meant Best Regards (without ? hahahaha... sorry)

--
Rafael E. Ferrero


2014-07-01 8:04 GMT-03:00 Rafael E. Ferrero :

> I see this too dangerous... it is not a good idea save uncrypted
> password... too many hacker attack result on public user-password list.
> Why not save encrypted password on the other application too?
>
> Best Regards?
>
> --
> Rafael E. Ferrero
>
>
> 2014-07-01 6:41 GMT-03:00 guillaume :
>
> Hi list,
>>
>> When registering a new user, or a password change, I need to register
>> that user, or his new password, in another application through an internal
>> API. I'm trying to catch the password from the different form they can be
>> found in, but without success. Even the signal pre_save is happening too
>> late (password is already encrypted). How can I see it just before it is
>> encrypted ?
>>
>> Thanks
>>
>> Guillaume
>>
>> --
>> 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/46c619d4-7499-4d77-afa5-01490cd06c0e%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/CAJJc_8WFp5JrG%3DXFzL19V1C0QVQTkRezZ%3DRpMuDnKLKPQKPBcA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: pre_save on password

2014-07-01 Thread Rafael E. Ferrero
I see this too dangerous... it is not a good idea save uncrypted
password... too many hacker attack result on public user-password list.
Why not save encrypted password on the other application too?

Best Regards?

--
Rafael E. Ferrero


2014-07-01 6:41 GMT-03:00 guillaume :

> Hi list,
>
> When registering a new user, or a password change, I need to register that
> user, or his new password, in another application through an internal API.
> I'm trying to catch the password from the different form they can be found
> in, but without success. Even the signal pre_save is happening too late
> (password is already encrypted). How can I see it just before it is
> encrypted ?
>
> Thanks
>
> Guillaume
>
> --
> 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/46c619d4-7499-4d77-afa5-01490cd06c0e%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/CAJJc_8XU7r6xLeiBmzoTq%3DtS57Bs6UjJP6qfjF2fypVZop%2B9HQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


pre_save on password

2014-07-01 Thread guillaume
Hi list,

When registering a new user, or a password change, I need to register that 
user, or his new password, in another application through an internal API. 
I'm trying to catch the password from the different form they can be found 
in, but without success. Even the signal pre_save is happening too late 
(password is already encrypted). How can I see it just before it is 
encrypted ? 

Thanks

Guillaume

-- 
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/46c619d4-7499-4d77-afa5-01490cd06c0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.