Re: Form Saving Related Issues

2016-10-31 Thread Andromeda Yelton
If your model has the uniqueness constraint, you should get a form error
message automatically. If you don't want your model to have that constraint
but you still want your form to throw an error message, you can add a
clean_ and a clean_ function
that check for uniqueness and raise ValidationError if it fails (see
examples here: https://docs.djangoproject.com/en/1.10/ref/forms/validation/
).

When the form saves successfully, the user will be redirected to the
success_url you provide. That template can have success message text.
Alternately, in your form_valid function in the view, you could add a
success message that will get added to whatever page you're redirecting to
(as long as you make sure your template is rendering messages) ->
https://docs.djangoproject.com/en/1.10/ref/contrib/messages/#adding-a-message

On Mon, Oct 31, 2016 at 1:55 AM, pradam programming <
pradam.programm...@gmail.com> wrote:

> Hi,
> Please I need an advice on the best approach to take on the following
> issues.
> I have create a form to save user details like first name,last
> name,email,mobile number etc...
>
> 1.Now I need to show error message (In Models i gave email and mobile no
> field as unique = True) when user enter a email id if email id exists in
> database show message like email id exists beside the email text field(also
> for  the mobile no) else proceed with form.
> 2.After i saving the form i need to show alert of success.
>
> regards,
> Pradam Abhilash
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAGGVXBOz6kQs%2BHhR%2BsrTUApOGnR7t50HHQuvSN_
> zJz6VMQosFw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAGGVXBOz6kQs%2BHhR%2BsrTUApOGnR7t50HHQuvSN_zJz6VMQosFw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology
Association: http://www.lita.org
http://andromedayelton.com
@ThatAndromeda <http://twitter.com/ThatAndromeda>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFE1XCbVpkpOboCKR_Xck-oTm2NJYCVQ6ssWZsBWRaNe3pQM9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: A Backup Model in Django?

2016-10-16 Thread Andromeda Yelton
I've found myself in the situation of needing to copy model data to new
model instances. This rapidly turned into a twisty sort of hell where I was
doing recursion on graphs in order to preserve all the foreign key
references (and then special-casing all the OneToOne fields, because
naively copying those will throw IntegrityErrors right and left...) Now it
is one of those unmaintainable-horror corners of the codebase that no one
wants to go near.

Just back up your whole database. If you're using postgres, pg_dump makes
this really straightforward.

On Sun, Oct 16, 2016 at 2:40 AM, Bernd Wechner 
wrote:

> A curious question I've had trouble finding an answer for alas. I have a
> model that I'd like to backup in the database in a backup model. This being
> the pro-forma so to speqk:
>
> from django.db import models
>
> class MyModel(models.Model):
>  # Declare fields 
>
> class MyModel_backup(MyModel):
>  def create(self):
>   self.objects = MyModel.objects.all()
>
> But there are two immediate problems.
>
>1. Deriving from MyModel reveals itself in the migration to be
>generating a model which has a single OneToOne reference to MyModel. That
>is ti does not appear to create a duplicate model at all. Which leaves me
>wondering how to create a duplicate model without repeating the code.
>
>2. I have no really idea how to copy all the objects of MyModel to a
>new model.
>
> I may be approaching it poorly and am open to better ideas. I'm used to
> doing it in SQL, essentially having an identically defined backup table,
> just copying data to that table before doing a (risky) table wide operation
> on the first.
>
> I could of course export a serialized backup to a disk file, but am
> exploring options for keeping one backup in the database itself.
>
> I'd rather, I admit hear options for doing that than philosophic
> appraisals of the benefits of an in-database copy vs, database exports.
>
> Regards,
>
> Bernd.
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/a19ba010-572b-4097-a988-f357cc5b6c31%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a19ba010-572b-4097-a988-f357cc5b6c31%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology
Association: http://www.lita.org
http://andromedayelton.com
@ThatAndromeda <http://twitter.com/ThatAndromeda>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFE1XCYW9cLixRSG2bmBM3Knm0hhf_4q%2BcZvuvvXcDPZmf9nKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Raw query returns 1 row but outputting multiple rows in template

2016-10-06 Thread Andromeda Yelton
What's in the get_digital_client_summary() function?

On Thu, Oct 6, 2016 at 6:18 AM, Thomas Brightwell <
thomas.brightw...@gmail.com> wrote:

> Hi,
>
> I have a raw query returning one row which is then shown 8 times in the
> template. I have debugged and there is only one line when this is executed
> in the shell and I do a simple for loop print output. So it seems to be
> something about the template tags?
>
> The raw query which definitely only returns one row (when executed in
> shell, mysql direct, debugged in pycharm):
>
> digital_clients = DigitalClient.objects.raw('''select
>> dig.id,
>> dig.client,
>> dig.digital_campaign_spend,
>> dig.job_page_impressions,
>> dig.event_page_impressions,
>> dig.profile_page_impressions,
>> dig.job_page_redirect_impressions,
>> dig.event_page_redirect_impressions,
>> dig.profile_page_redirect_impressions,
>> dig.applications,
>> dig.cost_per_application,
>> dig.cost_per_hire,
>> dig.hires,
>> dig.percentage_complete,
>> dig.offset_dotmailer_reach,
>> dig.offset_dotmailer_clicks,
>> sum(cam.client_link_clicks) as 'client_link_clicks',
>> sum(cam.reach) as 'reach'
>> from dashboard_digitalclient dig
>> left join dashboard_dotmailercampaign cam on dig.id =
>> cam.client_id
>> group by dig.id
>> order by dig.client''')
>
>
> Then of course in the view I'm passing it into the context for the
> template:
>
> digital_clients = get_digital_client_summary()
>> context = {
>> 'digital_clients': digital_clients,
>> 'last_refreshed': last_refreshed
>> }
>> return render(request, 'dashboard/all_clients_summary.html', context)
>
>
> Then I'm doing this in the template:
>
>>
>> {% for client in digital_clients %}
>> 
>> {{ client.client }}
>> {{ client.reach|default_if_none:
>> 0|add:client.offset_dotmailer_reach }}
>> {{ client.client_link_clicks|
>> default_if_none:0|add:client.offset_dotmailer_clicks }}
>> {{ client.job_page_impressions }}
>> {{ client.event_page_impressions }}
>> {{ client.profile_page_impressions }}
>> {{ client.job_page_redirect_impressions }}
>> {{ client.event_page_redirect_impressions }}
>> {{ client.profile_page_redirect_impressions }}
>> £{{ client.digital_campaign_spend }}
>> {{ client.percentage_complete }}%
>> {{ client.applications }}
>> {{ client.hires }}
>> £{{ client.cost_per_application }}
>> £{{ client.cost_per_hire }}
>> Client refresh
>> 
>> {% endfor %}
>
>
> And I get 8 rows in my table?
>
> Help would be much appreciated as I'm super stuck on this one...
>
> All the best,
>
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/dabd210b-06cf-4d28-8e36-a48e8d5cb7c5%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/dabd210b-06cf-4d28-8e36-a48e8d5cb7c5%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology
Association: http://www.lita.org
http://andromedayelton.com
@ThatAndromeda <http://twitter.com/ThatAndromeda>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFE1XCa_b%3DbvUK5eZdt7nhNVqXfD5kNnzewDGrGGhoMDSwB5PA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: For loop for ModelForm in Django

2016-10-04 Thread Andromeda Yelton
https://docs.djangoproject.com/en/1.10/topics/forms/#looping-over-the-form-s-fields

That said, testing for Boolean vs. non-Boolean fields is really more logic
than belongs in a template. You can manually lay out the form in the
template, specifying where each field should go and surrounding them with
your desired HTML, or you can use crispy forms (
https://django-crispy-forms.readthedocs.io/en/latest/) on the back end if
you want to be manipulating a lot of logic (and then let crispy take care
of generating HTML and making it look nice).

On Sun, Oct 2, 2016 at 6:58 AM, Ali khan  wrote:

> I need to iterate the form to get Boolean values in a single line. Please
> help me to figure out a way to iterate through model forms.
> Also I generally need to understand how to iterate through modelforms.
>
> App Model:
>
> class ProjectDetails(models.Model):
>  type = models.CharField(max_length=120)
>  tools = models.CharFiled(max_length=120, choices=tools)
>  reporting = models.BooleanField(defautl=False)
>  weekly_meeting = BooleanField(default=True)
>  def __unicode__(self):
>   return self.project_tools
>
> App Form:
> def ProjectDetailForm(forms.ModelForm):
>  class Meta:
>  model = ProjectDetails
>  fields = ["project_type", "project_tools", "reporting", "weekly_meeting"]
>
> App view:
> def project_info(request):
> template = 'project.html'
> form = ProjectDetailForm(request.POST or None)
> if form.is_valid():
> form.save(commit=True)
> return render(request, template, context={'form':form})
>
>
> App html file:
> 
> {% csrf_token %}
> {{ form }}
> 
> 
>
>
> Ali
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAAXvsY%3Df3QRBpuOvQMcyRQND8H_Ds8%2Bv-
> 3LREOJVhPzo_0qRPw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAAXvsY%3Df3QRBpuOvQMcyRQND8H_Ds8%2Bv-3LREOJVhPzo_0qRPw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology
Association: http://www.lita.org
http://andromedayelton.com
@ThatAndromeda <http://twitter.com/ThatAndromeda>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFE1XCaZygbTxG4TyTDwtBRa4JFkBz8X4%3DEAx_wDOHk3bLBODA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: cant start a new project ,just installed django

2016-10-04 Thread Andromeda Yelton
When I copy-pasted the error message into Google I got some stackoverflow
posts saying that you can get this error if you have two different versions
of Django installed; are you certain that your 1.10.2 install is the only
one on your system?

On Mon, Oct 3, 2016 at 5:59 PM, new user  wrote:

> followed the intro:
> https://docs.djangoproject.com/en/1.10/intro/tutorial01/
>
> when i run django-admin startproject mysite
>
> its prompt : "manage.py already exists, overlaying a project or app into
> an existing directory won't replace conflicting files" not matter what name
> i give to the project , its creating new dir wit the project name , and
> manage.py and this error. google didnt helped me and i saw someone
> complained it a bug. windows 10
>
>
>
> anyone?
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/f8aa3c2c-006b-4c01-b4b6-a93e3a33623e%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/f8aa3c2c-006b-4c01-b4b6-a93e3a33623e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology
Association: http://www.lita.org
http://andromedayelton.com
@ThatAndromeda <http://twitter.com/ThatAndromeda>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFE1XCYTWC9hhn1btENosVTD0oXb4%3DhV0HEULyDbbFiHwqT2Cw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Maintaining old django code

2016-09-06 Thread Andromeda Yelton
+1 to Erik's plan.

In deciding whether to stop at 1.8 or go all the way to 1.10 I'd ask myself
the following questions:

* Are there features from 1.10 (that aren't in 1.8) that I'd really like to
have? (channels is the big one for me)

* Are there important third-party dependencies that are only available for
1.8 and/or 1.10? Do those dependencies have a track record of keeping up
with new versions?  (https://djangopackages.org/ is indispensable here, and
will also help you find replacements for your unmaintained dependencies.)

* Given that there hasn't been much maintenance time budgeted in the past,
is there likely to be much maintenance time budgeted in the future? (if
not, I'd stick with 1.8, since that will be maintained longer than 1.10 - a
better place to be stuck at if you can't upgrade for a while. but if you're
going to have time to keep up with versions as they happen, then the
questions above are more important.)

On Tue, Sep 6, 2016 at 4:20 AM, Lekan Wahab  wrote:

> Good morning guys.
> I was handed a project at work which was written as far back as 2012.
> Quiet a lot of the packages used in the project are either no longer being
> maintained.
> Rebuilding the project from scratch is not option.
> There are way too many moving parts and way too many apps to rebuild it.
> Here are my questions:
>
> 1. In the scenario i am in, what would be the best approach to update this
> project or at least get it set up locally?
> 2.  Quite a lot of changes have been made between django 1.4 (which was
> originally used) and the current version(1.10), what would be the best
> version for me to update the project to.
> I mostly use 1.8 anyway.
> 3. Is there anyone who has or who is still using *unobase* here?
>
>
> Olamilekan
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAE6v7ocNHTh-MUepU1qKp_ZKVc8ofOuDFwebq37KWgqsG7i9Fg%
> 40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAE6v7ocNHTh-MUepU1qKp_ZKVc8ofOuDFwebq37KWgqsG7i9Fg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology
Association: http://www.lita.org
http://andromedayelton.com
@ThatAndromeda <http://twitter.com/ThatAndromeda>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFE1XCZba%3DofmPdSrRNg_DX9hYWusqV0PQ-07qyZQBT9a%2B6_rQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Error: int() argument must be a string or a number, not 'SimpleLazyObject'

2016-08-31 Thread Andromeda Yelton
 lookups,
> value)
> > File 
> > "C:\Users\Shazia\dd\lib\site-packages\django\db\models\fields\related.py"
> in get_lookup_constraint
> >   1745. lookup_class(target.get_col(alias, source),
> val), AND)
> > File "C:\Users\Shazia\dd\lib\site-packages\django\db\models\lookups.py"
> in __init__
> >   101. self.rhs = self.get_prep_lookup()
> > File "C:\Users\Shazia\dd\lib\site-packages\django\db\models\lookups.py"
> in get_prep_lookup
> >   139. return 
> > self.lhs.output_field.get_prep_lookup(self.lookup_name,
> self.rhs)
> > File 
> > "C:\Users\Shazia\dd\lib\site-packages\django\db\models\fields\__init__.py"
> in get_prep_lookup
> >   727. return self.get_prep_value(value)
> > File 
> > "C:\Users\Shazia\dd\lib\site-packages\django\db\models\fields\__init__.py"
> in get_prep_value
> >   985. return int(value)
> >
> > Exception Type: TypeError at /orders/4/
> > Exception Value: int() argument must be a string or a number, not
> 'SimpleLazyObject'
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/CAD83tOxhgfQGucutTQ%2BFScou0VORFJPhSXUnhFeiwqUD2Ty
> ETg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAD83tOxhgfQGucutTQ%2BFScou0VORFJPhSXUnhFeiwqUD2TyETg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology
Association: http://www.lita.org
http://andromedayelton.com
@ThatAndromeda <http://twitter.com/ThatAndromeda>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFE1XCZx3Yd5P5iADGt9HKngh2XD7-seYH8PFDPvD7XB%3Det1Lw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: 1.7.9 deployment stubbornly won't create a test database

2016-08-30 Thread Andromeda Yelton
What are do the relevant parts of your settings file say? In particular,
https://docs.djangoproject.com/en/1.7/topics/testing/overview/#the-test-database
says "If you want to use a different database name, specify NAME in the
TEST dictionary for any given database in DATABASES." - I would check there
to see if someone has overridden the default. There's also a little section
in the docs labeled "Finding data from your production database when
running tests?" that might be relevant to you.

(--keepdb is a great flag but sadly irrelevant as it was not introduced
until 1.8.)

On Mon, Aug 29, 2016 at 6:26 PM, Adam Hirsch 
wrote:

> I've been handed a fairly large and built-up django 1.7.9 installation
> with several dozen pre-existing in-house modules and a lot of history.
>
> For some reason, any attempt to * manage.py test * any of the existing
> modules runs tests against the live database specified in 
> *DATABASES['default']
> *rather than attempting to create a new test database.  I've written a
> couple of simple unit tests for a given module, generated a small fixture
> of data to apply to a blank schema for testing ... but I can't for the life
> of me find why this installation isn't creating a test_db. No errors, no
> failures ... just tests run against the production db.
>
> Anyone have a pointer to what might be going on, or concepts to look up? A
> simple Hello World install using the same django version on the same
> machine works exactly as the docs suggest it should: I see
>
> Creating test database for alias 'default' (':memory:')...
> [...]
> Destroying test database for alias 'default' (':memory:')...
>
>
> ... but there are no such lines in my real installation.  I'm baffled.
>
> Adam
>
>
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/ea373ba9-9c9e-4358-9c71-b3c0d1c4b3d9%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/ea373ba9-9c9e-4358-9c71-b3c0d1c4b3d9%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology
Association: http://www.lita.org
http://andromedayelton.com
@ThatAndromeda <http://twitter.com/ThatAndromeda>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFE1XCbL_cm1pYGMpo-gv%3D3z0WkmeYaQZTsvLzHMR56gHpM7_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error, with a very basic banking app

2016-08-26 Thread Andromeda Yelton
In my experience, CBVs are useful when the view you want to write is
basically a create, read, update, or delete operation on a single database
item, or a bunch of instances of the same model (...and it turns out a lot
of web app pages are just that). And they're useful because they let you do
that with almost no lines of code - they take care of all the things you'd
have to write over and over, and let you focus on the things that are
unique to your use case.

The farther away your business logic is from that, the more you need to
understand the actual methods available and the inheritance tree and so
forth. It took me a while to get over this hurdle too, but now that I have
I use CBVs exclusively.

On Fri, Aug 26, 2016 at 10:13 AM, Neil Hunt  wrote:

> heh heh. I don't fully appreciate the usefulness of CBV at the moment.
> Getting a simple example working helps as much as reading the tutorial.
> Thanks again for your help,
>
> Neil
>
> On Fri, Aug 26, 2016 at 2:24 PM, Sergiy Khohlov 
> wrote:
>
>> Never mind.
>>  Few year ago I  was thinking that moving to CBV is bad idea, but
>> suddenly  BUUUHHH !! in my head and everything was clear.
>>
>> Many thanks,
>>
>> Serge
>>
>>
>> +380 636150445
>> skype: skhohlov
>>
>> On Fri, Aug 26, 2016 at 3:40 PM, Neil Hunt  wrote:
>>
>>> Hello Serge,
>>>
>>> I can't believe that's all I have to add to get the class based views to
>>> work. It seems easier to get it to work than I thought it would be. Now
>>> that you've explained it. Thank you so much for that.
>>>
>>> Kind regards,
>>>
>>> Neil
>>>
>>> On Fri, Aug 26, 2016 at 11:46 AM, Sergiy Khohlov 
>>> wrote:
>>>
>>>>  Hello Neil,
>>>>
>>>>  It is nota problem  to use Class based view. Could you please  update
>>>> your views.py  with next code.
>>>>  Look like you would like to have detail  of the deposit in this case
>>>> add next string to the header
>>>>
>>>> from  django.views.generic import DetailView
>>>> from models import Account1, Person
>>>>
>>>>
>>>>  # next  you should create a special view class for each Account1
>>>>
>>>>
>>>>  class Deposit(DetailView):
>>>> model = Account1
>>>>
>>>>
>>>>   Of course  function Deposit is  useless
>>>>
>>>>  thats all.
>>>>
>>>>
>>>>  P.S. Look like better way is adding auth  and receive person using
>>>> auth data. In this case  every authorized person can  connect to his
>>>> account  using auth info and  account id
>>>>
>>>> Many thanks,
>>>>
>>>> Serge
>>>>
>>>>
>>>> +380 636150445
>>>> skype: skhohlov
>>>>
>>>> On Thu, Aug 25, 2016 at 8:27 PM, Neil Hunt  wrote:
>>>>
>>>>> Thank you so much Andromeda. I didn't know you could use class based
>>>>> views. I'll have a look at the documents. I don't know why I was trying to
>>>>> use them when I didn't need to.
>>>>>
>>>>> On Thu, Aug 25, 2016 at 4:23 PM, Andromeda Yelton <
>>>>> andromeda.yel...@gmail.com> wrote:
>>>>>
>>>>>> The stacktrace is helpful, thanks!
>>>>>>
>>>>>> The specific message with the AttributeError is helpful here:
>>>>>> `AttributeError: 'module' object has no attribute 'DepositView'`
>>>>>>
>>>>>> The line above it is `  File 
>>>>>> "/home/soupdragon/DJapps/banking/mybank/banking/urls.py",
>>>>>> line 8, in 
>>>>>> url(r'^deposit/$', views.DepositView.as_view(), name='deposit'),`
>>>>>>
>>>>>> So I checked to see if your views.py contains anything named
>>>>>> DepositView...and it does not. That's why the AttributeError is showing 
>>>>>> up.
>>>>>>
>>>>>> The `DepositView.as_view()` syntax is suitable for class-based views,
>>>>>> which means I expect to see something in your views.py to the effect of:
>>>>>>
>>>>>> class DepositView(View):
>>>>>>   def post(self, request, *args, **kwargs):
>>>>>> // the logic in your deposit() function actu

Re: Attribute error, with a very basic banking app

2016-08-25 Thread Andromeda Yelton
The stacktrace is helpful, thanks!

The specific message with the AttributeError is helpful here:
`AttributeError: 'module' object has no attribute 'DepositView'`

The line above it is `  File
"/home/soupdragon/DJapps/banking/mybank/banking/urls.py", line 8, in

url(r'^deposit/$', views.DepositView.as_view(), name='deposit'),`

So I checked to see if your views.py contains anything named
DepositView...and it does not. That's why the AttributeError is showing up.

The `DepositView.as_view()` syntax is suitable for class-based views, which
means I expect to see something in your views.py to the effect of:

class DepositView(View):
  def post(self, request, *args, **kwargs):
// the logic in your deposit() function actually belongs here

Have a look at the class-based views documentation to see what the
different classes are, and what options they provide you.

Alternately, your urls.py could reference views.deposit (which does exist)
instead of views.DepositView (which does not).

Hope this helps!

On Thu, Aug 25, 2016 at 11:14 AM, Neil Hunt  wrote:

> Thanks for your speedy reply, I've attached the stack trace
>
> On Thursday, August 25, 2016 at 4:00:16 PM UTC+1, ludovic coues wrote:
>>
>> Could you share the full stack trace you get when trying to run the
>> server ?
>> The attribute error should come with a ton of information like the
>> file and the line where the error occur.
>>
>> 2016-08-25 16:57 GMT+02:00 Neil Hunt :
>> > I've beem working on a simple banking app based on the Django tutorial.
>> > Thanks to your help it almost works now. It was working using templates
>> but
>> > after making some changes to get HttpResponseRedirect to work I changed
>> what
>> > was in the urls file like it shows in the tutorial. Now, the server
>> doesn't
>> > run. It says there's an attribute error. I've temporarily left the user
>> name
>> > and password in at the moment. I had a look at their tutorial how to do
>> a
>> > use the Django authentication system (thanks for telling me about that)
>> and
>> > I'm going to change that after I understand what's going on here. It's
>> > amazing how much you can do with Django. Do you think with time you get
>> more
>> > used to what different errors mean? The errors seem new and confusing
>> to me
>> > at the moment. Any help would be very much appreciated. Thanks in
>> advnace.
>> >
>> > --
>> > 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 https://groups.google.com/group/django-users.
>> > To view this discussion on the web visit
>> > https://groups.google.com/d/msgid/django-users/b30091ce-fcbf
>> -461e-869e-bba72eb9dcfe%40googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>>
>> Cordialement, Coues Ludovic
>> +336 148 743 42
>>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/b9b247a9-830d-4cc0-a441-5a8013899f13%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b9b247a9-830d-4cc0-a441-5a8013899f13%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology
Association: http://www.lita.org
http://andromedayelton.com
@ThatAndromeda <http://twitter.com/ThatAndromeda>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFE1XCbjKrqcXNmF2wUZottJLJr37SabJdq5ihZpWGiUiCLNDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Clarifying Project vs Apps

2016-08-24 Thread Andromeda Yelton
My feeling/practice on apps is: each app is a one-word informative noun. It
contains the models that are logically grouped under that noun (and the
views, urls, etc required to interact with those models on the front end).

If there isn't a single word that logically represents all my models, then
they need to be separated into multiple apps. (And if models.py has gotten
long enough that it's unwieldy, it probably wants to be split.)

So, e.g., "companies" or "invoices" or "customers" or "reports" are all
perfectly decent app concepts.

Also, _Two Scoops of Django_ is a helpful book for developing Django best
practice intuitions.

On Wed, Aug 24, 2016 at 11:48 AM, Rich Shepard 
wrote:

>   While I think that I understand the differences between a project and its
> apps there remains one point of uncertainty. I've not found the answer,
> although it might be in the 1.10 docs or on the Web and I've missed it.
>
>   If the project represents the entire database, do the apps represent
> individual tables? That is, should my project have a separate app for each
> table with its models, templates, and views with templates of joined tables
> in the main project subdirectory? Or are all tables in a single app?
>
> TIA,
>
> Rich
>
>


-- 
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology
Association: http://www.lita.org
http://andromedayelton.com
@ThatAndromeda <http://twitter.com/ThatAndromeda>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFE1XCbixOV-66k-RwCYHb9io0UCyZ%2BJZx0asFvRiZWXioDL5A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: beginner . problem simple form.

2016-08-22 Thread Andromeda Yelton
Is 'dojo.views.reportaralumnos' an appropriate argument for redirect()? See
https://docs.djangoproject.com/en/1.10/topics/http/shortcuts/#redirect -
it's looking for the name of a URL or the actual callable view object (such
as you might feed to reverse() -
https://docs.djangoproject.com/en/1.10/ref/urlresolvers/#django.urls.reverse),
not the import path of a view.

On Sun, Aug 21, 2016 at 6:16 AM, Jordi Fernandez 
wrote:

> hi,
>
> I have my firts application django it's fine. . But! I have a problem with
> a simple form. I  think this  is a problem the my experience of all entorn
> ( html, form action, ..)
>
> the problem is when a submit my form is a eror -> ERROR LOADING PAGE
>
> if I test my script I not received a method post. why?
>
>
>
> thank you
>
>
> *This is my template form*
>
> {% csrf_token %}
> {{ form.name.errors }}
> 
>
> {{form.as_p}}
>
> 
> 
>
> 
>
>
> *this is my wiew*
>
> def crearasistenciaclasse(request):
> #return HttpResponse('ok')
>
> if request.method == "POST":
> form = CrearasistenciaclasseForm(request.POST)
> if form.is_valid():
>Asistencia = form.save()
>return redirect('dojo.views.reportaralumnos')
> else:
> user = 6
> form = CrearasistenciaclasseForm(my_arg=user)
>
> return render_to_response('asistencias/crearasistenciaclasse.html',
> {'form': form})
>
>
>
>
>
>
>
>
>
> this is my form
>
> class CrearasistenciaclasseForm(forms.Form):
> alumnos = forms.ModelChoiceField(queryset=Alumno.objects.all())
> classesobertes = forms.ModelChoiceField(queryset=Classe.objects.
> filter(estado='A'))
> def __init__(self, *args, **kwargs):
> my_arg = kwargs.pop('my_arg')
> super(CrearasistenciaclasseForm, self).__init__(*args, **kwargs)
>
> self.fields['classesobertes'].label = "Classe"
>
> self.fields['alumnos'].initial = my_arg
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/71bb6ab8-e14a-47aa-91ad-57d4ac29e6f0%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/71bb6ab8-e14a-47aa-91ad-57d4ac29e6f0%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology
Association: http://www.lita.org
http://andromedayelton.com
@ThatAndromeda <http://twitter.com/ThatAndromeda>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFE1XCZWYdU8Z1E34AdnzKq%2B%2Bd96kKdRn4GM%3DxMDYzq56UATbw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: newcomer to django testing

2014-06-09 Thread Andromeda Yelton
/core/management/base.py",
>> > line 415, in handle
>> > return self.handle_noargs(**options)
>> >   File
>> >
>> "/home/monobot/.local/lib/python2.7/site-packages/south/management/commands/syncdb.py",
>> > line 103, in handle_noargs
>> > management.call_command('migrate', **options)
>> >   File
>> >
>> "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py",
>> > line 159, in call_command
>> > return klass.execute(*args, **defaults)
>> >   File
>> > "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py",
>> > line 285, in execute
>> > output = self.handle(*args, **options)
>> >   File
>> >
>> "/home/monobot/.local/lib/python2.7/site-packages/south/management/commands/migrate.py",
>> > line 111, in handle
>> > ignore_ghosts = ignore_ghosts,
>> >   File
>> >
>> "/home/monobot/.local/lib/python2.7/site-packages/south/migration/__init__.py",
>> > line 220, in migrate_app
>> > success = migrator.migrate_many(target, workplan, database)
>> >   File
>> >
>> "/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py",
>> > line 305, in migrate_many
>> > result = self.migrate(migration, database)
>> >   File
>> >
>> "/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py",
>> > line 134, in migrate
>> > result = self.run(migration, database)
>> >   File
>> >
>> "/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py",
>> > line 115, in run
>> > return self.run_migration(migration, database)
>> >   File
>> >
>> "/home/monobot/.local/lib/python2.7/site-packages/south/migration/migrators.py",
>> > line 86, in run_migration
>> > south.db.db.execute_deferred_sql()
>> >   File
>> > "/home/monobot/.local/lib/python2.7/site-packages/south/db/generic.py",
>> line
>> > 318, in execute_deferred_sql
>> > self.execute(sql)
>> >   File
>> > "/home/monobot/.local/lib/python2.7/site-packages/south/db/generic.py",
>> line
>> > 282, in execute
>> > cursor.execute(sql, params)
>> >   File
>> "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py",
>> > line 53, in execute
>> > return self.cursor.execute(sql, params)
>> >   File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py",
>> line 99,
>> > in __exit__
>> > six.reraise(dj_exc_type, dj_exc_value, traceback)
>> >   File
>> "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py",
>> > line 53, in execute
>> > return self.cursor.execute(sql, params)
>> > django.db.utils.ProgrammingError: relation "usuario_usuario" does not
>> exist
>> >
>> > So you could understand usuario is 1 of my apps and Usuario is one
>> model in
>> > there and i use south in my application.
>> >
>> > Seems that the test module needs an already functional database before
>> > testing but that isnt ilogical because it deletes the database and
>> creates
>> > 1other database...
>> >
>> >
>> > Any help would be welcomed.
>> >
>> > --
>> > monoBOT
>> > Visite mi sitio(Visit my site): monobotblog.alvarezalonso.es
>> >
>> > --
>> > 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%2BxOsGCEzE6M9SHs2MFfk-XGmNSyUSsBdn6Hz-ypfH7E%3D-CjiA%40mail.gmail.com
>> .
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>> Esaú Rodríguez
>> esa...@gmail.com
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from th

Re: Reference to form cleaned data field throws TypeError: 'exceptions.AttributeError' object is not callable

2014-06-03 Thread Andromeda Yelton
x/29.0',
>  'HTTP_X_REQUESTED_WITH': 'XMLHttpRequest',
>  'PATH_INFO': u'*/prereg_check/*',
>  'QUERY_STRING': '',
>  'REMOTE_ADDR': '',
>  'REMOTE_PORT': '37998',
>  'REQUEST_METHOD': 'POST',
>  'REQUEST_URI': '*/prereg_check/*',
>  u'SCRIPT_NAME': u'',
>  'SERVER_NAME': '.com',
>  'SERVER_PORT': '443',
>  'SERVER_PROTOCOL': 'HTTP/1.1',
>  'UWSGI_SCHEME': 'https',
>  'uwsgi.node': '.com',
>  'uwsgi.version': '2.0.4',
>  'wsgi.errors': ,
>  'wsgi.file_wrapper': ,
>  'wsgi.input': ,
>  'wsgi.multiprocess': True,
>  'wsgi.multithread': False,
>  'wsgi.run_once': False,
>  'wsgi.url_scheme': 'https',
>  'wsgi.version': (1, 0)}>
>
>
> This looks like a memory leak to me. Has anyone else seen this?
> Thanks in advance,
> ~G~
>
> --
> 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/11ddf2f6-7a07-4c1e-86db-b7e0223546ee%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/11ddf2f6-7a07-4c1e-86db-b7e0223546ee%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andromeda Yelton
Board of Directors, Library & Information Technology Association:
http://www.lita.org
Advisor, Ada Initiative: http://adainitiative.org
http://andromedayelton.com
@ThatAndromeda <http://twitter.com/ThatAndromeda>

-- 
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/CAFE1XCbywTwW%2BS8_0d6eoJWVYPn_KnXNcZv8eWkc5f%3D-MqqiMA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to use CreateView with crispy-forms

2014-05-28 Thread Andromeda Yelton
The | crispy filter provides only minimal (though stylish) rendering - if
you want to render all the cool stuff in your helper you need to do {%
crispy form %}.

Andromeda Yelton
LITA Board of Directors, Director-at-Large, 2013-2016
http://andromedayelton.com
@ThatAndromeda


On Wed, May 28, 2014 at 8:43 AM, <9devm...@gmail.com> wrote:

> I want to use CreateView along with crispy-forms generated layout.
> However, it seems that everything I pass to *self.helper* in *forms.py*is 
> ignored. Form renders nicely, but only with fields generated by
> CreateView - all fields passed to *Layout* are missing.
>
> My views.py
>
>> class MyView(CreateView):
>> form_class = MyForm
>> model = MyModel
>>
>> def form_valid(self, form):
>> pass
>>
>> My forms.py:
>
>> from django.forms import ModelForm, Textareafrom crispy_forms.helper import 
>> FormHelperfrom crispy_forms.layout import Submit, Layoutfrom 
>> crispy_forms.bootstrap import FormActions
>> from .models import MyModel
>> class MyForm(ModelForm):
>>
>> def __init__(self, *args, **kwargs):
>> super(MyForm, self).__init__(*args, **kwargs)
>> self.helper = FormHelper(self)
>> self.helper.form_method = 'POST'
>> self.helper.add_input(Submit('submit', 'Submit'))
>> self.helper.layout = Layout(
>> FormActions(Submit('BlahBlah', 'BlahBlah', 
>> css_class='btn-primary')))
>>
>> class Meta:
>> model = MyModel
>> fields = ['xxx', 'yyy']
>>
>> My image_form.html:
>
>> {% load crispy_forms_tags %}...> enctype="multipart/form-data">
>> {% csrf_token %}
>> {{ form|crispy }}
>>
>> What else should I do to make it work?
>
> --
> 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/2555778c-3f3f-43b4-8670-80ea8abdd1ba%40googlegroups.com<https://groups.google.com/d/msgid/django-users/2555778c-3f3f-43b4-8670-80ea8abdd1ba%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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/CAFE1XCZks3sO_rHtAhOno7%3DGjuoPFsOizFMu6FDSiSGaYLPRCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: why I change url is showing other user's data?

2014-05-26 Thread Andromeda Yelton
The urlpattern is telling your view (I assume a subclass of UpdateView?)
which instance of your User model to edit, but that's all the urlpattern
gets you - there's nothing built in about permissions. You need to write
permission restrictions yourself.

There's a whole bunch of ways you can do this. Something I've done:

from django.core.exceptions import PermissionDenied

[...]

class UserUpdateView(UpdateView):
[...]

def dispatch(self, request, *args, **kwargs):
if not self.request.user == self.object:
raise PermissionDenied
super(UserUpdateView, self).dispatch(request, *args, **kwargs)

I can think of a couple other things you might try and I don't know what's
most stylish, but that'll work.

Andromeda Yelton
LITA Board of Directors, Director-at-Large, 2013-2016
http://andromedayelton.com
@ThatAndromeda


On Sat, May 24, 2014 at 7:21 PM, Carlos Perche  wrote:

> for exemple, I have following url:
> http://tenant.com:8000/accounts/test1/edit/
>
> when my user right authenticated is test1, but if I change the url to
> http://tenant.com:8000/accounts/admin/edit/, the data of user admin is
> showing in profile form and if I change and save this form the admin's data
> is update.
>
> test1 is a simple user, no superuser nor staff, but have object permission
> for save, delete, change and view profile
>
> how do I protect the other user's data?
>
> sorry my english
>
> --
> 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/8025d812-6b2f-4a60-8538-6ea060b0fa34%40googlegroups.com<https://groups.google.com/d/msgid/django-users/8025d812-6b2f-4a60-8538-6ea060b0fa34%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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/CAFE1XCb3TzbjCQYo%2Bt_trECmsknyirxCpyOByKZjmb1svH_RHA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.