Re: Best approach to handling different types of Users

2011-08-21 Thread dfolland
Like I said use the "Groups" and then like what was suggested
"Permissions".  That should handle what your are trying to do and not
introduce any conflicts.

On Aug 18, 9:17 am, dfolland <dfoll...@nex-tech.com> wrote:
> Try using "Groups" that is part of the Django user authentication.
>
> https://docs.djangoproject.com/en/dev/topics/auth/
>
> On Aug 18, 6:56 am, Cameron <cameronma...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hi, I'm wondering if anyone can help shed some light on the best
> > approach is too creating different Users. I'm trying to make a online
> > shop, that features two types of Users, "Customers" and "Merchants".
> > The power of each Users vary greatly, Customers can buy items from
> > Merchants and Merchants can (as you would expect) list new products,
> > edit them. Merchants required additional information compared to
> > Customers (such as Address, Contact Info, Payment details).
>
> > Now hows the best way to handle this? I've read that subclassing the
> > User class is bad (I'm not entirely sure why though). Most examples
> > try to extend the User class, with a UserProfile class with a OneToOne
> > relationship to the User class (like thishttp://pastebin.com/GQVLrVTx).
> > Is it better to extend that to a UserProfileMerchant and
> > UserProfileCustomer, or have a single UserProfile, and have a boolean
> > field to indicate if the account is a Merchant? (both examples in the
> > following -http://pastebin.com/F8ZenCa1)
>
> > Any advice on the matter would be greatly 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.



Re: Best approach to handling different types of Users

2011-08-18 Thread dfolland
Try using "Groups" that is part of the Django user authentication.

https://docs.djangoproject.com/en/dev/topics/auth/



On Aug 18, 6:56 am, Cameron  wrote:
> Hi, I'm wondering if anyone can help shed some light on the best
> approach is too creating different Users. I'm trying to make a online
> shop, that features two types of Users, "Customers" and "Merchants".
> The power of each Users vary greatly, Customers can buy items from
> Merchants and Merchants can (as you would expect) list new products,
> edit them. Merchants required additional information compared to
> Customers (such as Address, Contact Info, Payment details).
>
> Now hows the best way to handle this? I've read that subclassing the
> User class is bad (I'm not entirely sure why though). Most examples
> try to extend the User class, with a UserProfile class with a OneToOne
> relationship to the User class (like thishttp://pastebin.com/GQVLrVTx).
> Is it better to extend that to a UserProfileMerchant and
> UserProfileCustomer, or have a single UserProfile, and have a boolean
> field to indicate if the account is a Merchant? (both examples in the
> following -http://pastebin.com/F8ZenCa1)
>
> Any advice on the matter would be greatly 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.



Re: Allow only one record in admin.ModelAdmin !

2011-05-04 Thread dfolland
Here is a way that I set up a settings model.

class YourSettings(models.Model):
ID_CHOICES = ((1,'Settings is a single record'),)
id = models.IntegerField(primary_key=True, choices=ID_CHOICES,
default=1)
... then the other fields for your settings.

On May 4, 12:11 am, Toninho Nunes  wrote:
> Hi,
>
> I have a table named Config, I need just only to limit to one record,
> are there a method or property to do this? any tip ou advice how to
> proceed? I use the admin.ModelAdmin.
>
> details:
> Django Version 1.3
> Ubuntu 10.10 - 64bits
> PostGresql 8.4
>
> Thanks,
>
> Toninho Nunes

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



Re: want small inventory project

2011-04-07 Thread dfolland
You might want to check out Django resources.

http://code.djangoproject.com/wiki/DjangoResources#Open-SourceDjangoprojects

On Apr 7, 6:11 am, GOUTAM KUMAR RANA  wrote:
> can any one please give link for some inventory site with source
> code..
>
> ie user management, inventory(buy/sell   --- add delete modify
> products), POS(pont of sale), reports.
>
> thanks

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



Re: How to concatenate a list of Q objects?

2010-04-09 Thread dfolland
If you are looking for "OR" then use the "Q object".

see 
http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects

On Apr 7, 11:39 am, Daniel  wrote:
> Hi,
>
> Thank you for your help everyone.  I know that I need to learn python
> better, and I did read those articles.  What is still a bit unclear to
> me, though, is how could I add an "OR" or "AND" separator between Q
> objects?
>
> So I have a list of qobjects like [qObj1, qObj2, qObj3].
>
> What I want is something like Sample.objects.filter((qObj1 | qObj2),
> qObj3)
>
> I know that the default is for all Q objects to be "ANDed" together.
> I think the join operation is not going to work here, nor is
> concatenation, but is there something obvious that I'm missing?
>
> THANK YOU :>
>
> On Apr 6, 7:14 am, Vinicius Mendes  wrote:
>
> > I recommend you to read more documentation about python. It's a basic python
> > feature. You can read more about it here:
>
> >http://www.saltycrane.com/blog/2008/01/how-to-use-args-and-kwargs-in-...
>
> > Try this:
>
> > Sample.objects.filter(*qObjects)
>
> > __
> > Vinícius Mendes
> > Solucione Sistemashttp://solucione.info/
>
> > On Tue, Apr 6, 2010 at 2:54 AM, Aaron  wrote:
> > > Sample.objects.filter(*qObjects)
>
> > > On Apr 6, 1:10 am, Daniel  wrote:
> > > > Hi, I think that this must be super easy, but I'm kind of stumped.
>
> > > > I have a list qObjects = [qObject1, qObject2, qObject3]
> > > > What I'd like is to form this query:  Sample.objects.filter(qObject1,
> > > > qObject2, qObject3)
>
> > > > How would I accomplish what I need?  Thanks!
>
> > > --
> > > You received this message because you are subscribed to the Google Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@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.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Re: Strange problem when starting project in Windows XP

2009-12-18 Thread dfolland
idle.pyw is the gui version of the python idle editor.  Sounds like
you've got file extension .py associated with it, instead of python.

On Dec 18, 11:59 am, OkaMthembo  wrote:
> Hi Dane,
>
> Yes, when you have to specify an absolute path to get it working, it
> definitely sounds like a PATH environ config. problem. When you check your
> PATH variables, do you see the folder to django-admin.py listed?
>
> Regards,
> Lloyd
>
>
>
> On Fri, Dec 18, 2009 at 7:27 PM, Dane  wrote:
> > It worked with 'python c:\python26\scripts\django-admin.py
> > startproject newsite'. Does that mean the PATH got messed up somehow?
>
> > On Dec 18, 7:52 am, Shawn Milochik  wrote:
> > > What happens when you type 'python django-admin.py'?
>
> > > If that doesn't work, try replacing 'python' there with the full path to
> > your Python executable in Windows. I've never heard of this problem, but it
> > sounds like it could be something odd in the environment.
>
> > > Shawn
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@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.
>
> --
> Regards,
> Sithembewena Lloyd Dubehttp://www.lloyddube.com

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.




Re: Unicode heisenbug whilst running a management command

2009-11-17 Thread dfolland
I've dealt with this by manipulating the data with Python codecs.

import codecs

new_value= codecs.decode(current_value, 'utf-8', 'ignore')

the default option is 'strict' which will raise a ValueError that
you've experienced, 'ignore' will drop the offending character, and
'replace' allows you to replace the malformed data with a suitable
replacement marker.

sometimes I use a try/except like this

try:
new_value= u"%s" % current_value
except:
import codecs
new_value= codecs.decode(current_value, 'utf-8', 'ignore')


On Nov 17, 9:14 am, Tom Evans  wrote:
> Hi all
>
> I'm encountering a difficult to solve unicode problem whilst saving data to
> the database. Worst of all, any attempt to reduce it to a simple test case,
> or reproduce it in the console fail(!). This is on django 1.0.
>
> The process encountering the error is a simple daemon, run from a management
> command [1]. The process looks up a task [2] to run and executes it. After
> the task has finished executing, it updates the generated_content member on
> the model, either to contain any pertinent error messages if there was a
> failure, or to store rendered HTML if the task was successful.
>
> The problem occurs when the generated HTML contains particular unicode
> characters (in this case, right single quotation mark, \u2019), which for
> some reason prompts django or MySQLdb to decide to convert it to unicode.
> The unicode HTML comes from rendering a django template; here's the snippet
> that generates the HTML:
>
>       cdict = { ... } # left out; template renders correctly, so not
> important..
>       ctxt = Context(cdict)
>       from django.template import loader
>       content = loader.render_to_string('the_template.html',
> context_instance=ctxt)
>       self.task.generated_content = content
>
> This code is called from MigrationTask::execute() - this is in the (working)
> PerformMigration class - and is the last thing that happens before we call
> save() on the modified instance. Apart from the generated_content, the only
> other thing that changes on this model as a result of this code is the
> status attribute.
>
> When we do call save(), the following traceback is produced:
>
> Traceback (most recent call last):
>   File
> "/usr/local/www/django/ssosp/externals/identity_provider/tasks/management/c­ommands/taskrunner.py",
> line 44, in handle
>     task.execute()
>   File
> "/usr/local/www/django/ssosp/externals/identity_provider/tasks/models.py",
> line 39, in execute
>     self.save()
>   File
> "/usr/local/www/django/ssosp/root/lib/python2.5/site-packages/django/db/mod­els/base.py",
> line 307, in save
>     self.save_base(force_insert=force_insert, force_update=force_update)
>   File
> "/usr/local/www/django/ssosp/root/lib/python2.5/site-packages/django/db/mod­els/base.py",
> line 358, in save_base
>     rows = manager.filter(pk=pk_val)._update(values)
>   File
> "/usr/local/www/django/ssosp/root/lib/python2.5/site-packages/django/db/mod­els/query.py",
> line 429, in _update
>     return query.execute_sql(None)
>   File
> "/usr/local/www/django/ssosp/root/lib/python2.5/site-packages/django/db/mod­els/sql/subqueries.py",
> line 117, in execute_sql
>     cursor = super(UpdateQuery, self).execute_sql(result_type)
>   File
> "/usr/local/www/django/ssosp/root/lib/python2.5/site-packages/django/db/mod­els/sql/query.py",
> line 1700, in execute_sql
>     cursor.execute(sql, params)
>   File
> "/usr/local/www/django/ssosp/root/lib/python2.5/site-packages/django/db/bac­kends/mysql/base.py",
> line 83, in execute
>     return self.cursor.execute(query, args)
>   File "/usr/local/lib/python2.5/site-packages/MySQLdb/cursors.py", line
> 151, in execute
>     query = query % db.literal(args)
>   File "/usr/local/lib/python2.5/site-packages/MySQLdb/connections.py", line
> 247, in literal
>     return self.escape(o, self.encoders)
>   File "/usr/local/lib/python2.5/site-packages/MySQLdb/connections.py", line
> 180, in string_literal
>     return db.string_literal(obj)
> UnicodeEncodeError: 'ascii' codec can't encode character u'\u2019' in
> position 1182: ordinal not in range(128)
>
> If I set a break point where we generate the content, print out
> repr(content), copy paste that into a django python shell and assign it to a
> task's generated_content property, it saves correctly.
>
> If I manually change content to u'\u2019' inside the debugger, it also saves
> correctly. It also works correctly for u'\u2019'*2048, just in case size of
> string matters.
>
> The database and all tables are set to UTF-8 in mysql. My locale is
> correctly set up in both cases (en_GB.UTF-8). I'm very confused as to why it
> is attempting to convert it to ascii :/
>
> Any hints/tips greatly appreciated.
>
> Cheers
>
> Tom
>
> [1]http://pastebin.com/m9e23563
> [2]http://pastebin.com/m564e1cd7

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send