Monday, September 30, 2013

Re: Dealing with redundant JS inclusions at template levels

On Mon, Sep 30, 2013 at 6:11 AM, Rafael E. Ferrero
<rafael.ferrero@gmail.com> wrote:
> I Dont know your design, usually i include the js library on base template
> and my apps templates extend from that... or just put another base template
> for every app...
>
> If you have some example code or tell us why you do that then we be more
> helpfull

My setup looks like this:

Django 1.5

Project/app structure:

mysite/ # Project root
mysite/
settings.py # INSTALLED_APPS includes 'foo', a reusable app
templates/
base.html # Project base template, includes jQuery &
# Bootstrap JS for project
static/ # Static assets for project
js/
jquery.js
bootstrap.min.js


foo/ # Reusable app
templates/
foo/
index.html # app template, extends 'base.html'. Requires
# and includes jQuery and Bootstrap JS for app
static/ # Static assets for 'foo' app
foo/
js/
jquery.js
bootstrap.min.js
app.js

So when 'index.html' from the foo app is rendered, the JS imports look
like this:


<script type="text/javascript" src="/static/js/jquery.js"></script>
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>

<script src="/static/foo/js/jquery.js"></script>
<script src="/static/foo/js/app.js"></script>
<script src="/static/foo/js/bootstrap.min.js"></script>
</div> <!-- end container -->
</body>
</html>

...because both the project and the reusable app are using jQuery and
Bootstrap JS, loading them twice on the same page results in screwed
up JS behavior.


Also,

On Mon, Sep 30, 2013 at 6:18 AM, Dariel Dato-on <oddrationale@gmail.com> wrote:
> You can consider using Django Sekizai to manage your Javascript and CSS
> imports:
>
> https://django-sekizai.readthedocs.org/en/latest/

Seems interesting, I'll look into it more. To be honest, I think I'm
looking for a best practice rather than a solution; how are others
managing redundant JS includes when combining their own projects and
reusable apps? I imagine there's no app required to do this
intelligently.

DS



> 2013/9/30 Darren Spruell <phatbuckett@gmail.com>
>>
>> Spent a bit of time debugging some faulty JavaScript library
>> functionality before I realized that I had included the library at
>> multiple levels in the project - first site-wide in the base template,
>> and then within a app. I think I ran into this:
>>
>>
>> http://stackoverflow.com/questions/4891278/what-is-the-danger-in-including-the-same-javascript-library-twice
>>
>> Is there a good design pattern to this situation, bearing in mind a
>> need to include JS libraries at project level and a desire to use apps
>> that include the same libraries in an attempt to be reusable?
>>
>> Looking at jQuery and Bootstrap for this.
>>
>> --
>> Darren Spruell
>> phatbuckett@gmail.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+unsubscribe@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/CAKVSOJVxQ8XF9wojenv6FW53CTHw28xMsD7LCoYas5%2BRchxtBA%40mail.gmail.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
> --
> Rafael E. Ferrero
>
> --
> 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+unsubscribe@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_8XTE884Y9oCCK1StrtRGxt0Jvd%3DcJiOfboNOdarK%3DC05A%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Darren Spruell
phatbuckett@gmail.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+unsubscribe@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/CAKVSOJU9zxR3qJQHFq22X2oRPeTyz38SF%2B9QNfTkuExMiEwGYg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Django Consultant/Architect

Hi

We're looking for Django Consultant/Architect who can assist in the assessment of a Python/Django based application. The assessment will involve looking various aspects of architecture, design, and code so the ideal candidate would have the necessary experience to provide a perspective on best practices, pitfalls, design patterns, libraries, frameworks, development tools, etc. for Python/Django. Experience with a platform such as J2EE or .NET would be very beneficial as it would help us and the client compare and contrast Python with more widely adopted enterprise technologies. Also, this person may also need to help train/ramp-up other team members (locally or remote) on Python/Django.

Contact: Vishwas (9986699065)

Vachan.jodalli@gmail.com

Regards

Vishwas

 

--
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+unsubscribe@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/26d8cf71-b906-4243-9f57-517556707edc%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Интегрция django и 1c

Sorry, I asked the question in the wrong group.


On 30 September 2013 17:41, Rafael E. Ferrero <rafael.ferrero@gmail.com> wrote:
No Che!, no lo usé nunca... ni siquiera tenía idea de su existencia, igualmente veo muchas urls con la extensión PHP que no me hacen ninguna gracia :P

Saludos !!


2013/9/30 Иван Земцов <inzem77@gmail.com>
Всем привет!
Кто нибудь обладает более подробной информацией по протоколу обмена чем тут ?
http://v8.1c.ru/edi/edi_stnd/131/

Может у кого-то есть какая-нибудь реализация данного протокола?

--
С уважением, Иван

--
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+unsubscribe@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/CACt1%2BqctgCtF0qbmxOtmFi2rRQ06zXn2AMyyPh_%3D5cswBUNA6w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
Rafael E. Ferrero

--
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+unsubscribe@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_8V-9xdN38dsBOmy_1CngU4UM2aBCf36vUvkcWc2LVLFoA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
С уважением, Иван

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@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/CACt1%2BqfNMm4ukxY%3DOYrHOZKo%3DjgvcMPTTv2ZFwW%2Bd-xFg04oAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Multiple versions of Django

On Mon, 30 Sep 2013, Jasvir Singh wrote:

> Is it possible to install multiple versions of Django on single ubuntu server.
> If yes, please tell me how to do this.
@all, thanks for their help but my requirement is to use multiple
versions of django on single server. I have to use it apache web server.
Here is the full scene.
I have django 1.4.2 installed on ubuntu server which uses apache.
There are several django based applications installed on it. All of
them are working on django 1.4.2 . But recently I have developed an
another application using django 1.5.2. Now I have to install that
application on server, but problem is that, I can not remove django
1.4.2 from server. For this purpose, I have tried virtual environment
using steps given in following link:
http://serverfault.com/questions/413879/how-can-i-run-two-django-versions-in-the-same-server

But when I wish to use to application, I have to switch on virtual
environment and start then django server. I want that app to run without
using django server.
Hope that I am able to explain the problem. If there is any confusion, please ask.


--
Jasvir Singh Grewal
Blog: jasvirsinghgrewal91.wordpress.com

:
####[ GNU/Linux One Stanza Tip (LOST) ]#######################

Sub : To randomly play mp3 songs from a directory LOST #243

mpg123 -z /path/to/mp3s/*.mp3
This will randomly play mp3 songs from the specified folder.

####[ajitabhpandey (at) users.sourceforge.net]################
:

--
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+unsubscribe@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/20131001031536.GA9891%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Testing: @override_settings(AUTH_USER_MODEL='auth.User') no working.

Thanks, it worked.
Changing @override_settings(AUTH_USER_MODEL='auth.User') for
@override_settings(AUTH_USER_MODEL='auth.CustomUser') made the trick.

On Sun, Sep 29, 2013 at 9:09 PM, Russell Keith-Magee
<russell@keith-magee.com> wrote:
>
> On Mon, Sep 30, 2013 at 7:27 AM, Serge G. Spaolonzi <serge@cobalys.com>
> wrote:
>>
>> Hi,
>>
>> I am failing to override the AUTH_USER_MODEL settings for a unittest, it
>> throws:
>>
>> "Manager isn't available; User has been swapped for 'None'"
>>
>> Is it possible to override AUTH_USER_MODEL in the unittest?
>> My goal is to use the default user model provided by django for the test
>> only.
>
>
> Yes, it is possible. That's why the approach is documented:
>
> https://docs.djangoproject.com/en/dev/topics/auth/customizing/#custom-users-and-testing-fixtures
>
> If you're getting an error, It sounds like something else is going wrong in
> your test suite -- my guess would be that you haven't got the auth app in
> INSTALLED_APPS. However, it's impossible to say for sure without seeing more
> code.
>
> Yours,
> Russ Magee %-)
>
> --
> 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+unsubscribe@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.
> For more options, visit https://groups.google.com/groups/opt_out.



--
Serge G. Spaolonzi
Cobalys Systems
http://www.cobalys.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+unsubscribe@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%2BrwjWXc-k166BhY5%3DRRM9LR21MFTyf9KqDMSozKErohbMEchw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Django-cart. How to run method add_to_cart?

Hi, I have this same problem.
I'm looking for answer everywhere.
enemybass could implement?
If someone can help me with this

[] s

Em quarta-feira, 26 de setembro de 2012 05h33min24s UTC-3, enemybass escreveu:
https://github.com/bmentges/django-cart

I'm a total newbie to Django. How to run method add_to_cart? In template I would have button "add to cart".

Thanks.

def add_to_cart(request, product_id, quantity):      product = Product.objects.get(id=product_id)      cart = Cart(request)      cart.add(product, product.unit_price, quantity)
My model look something like this:
class Product(models.Model):      name = models.CharField(max_length=50)      slug = models.SlugField()      unit_price = models.DecimalField(max_digits=5, decimal_places=2)      category = models.ManyToManyField(Category)        class Meta:          verbose_name = "Product"          verbose_name_plural = "Products"        def __unicode__(self):          return self.name

--
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+unsubscribe@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/cfabbfd6-01ac-4b40-b887-ea7d7cd59c06%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Textarea and initial value

Thanks, I thought I checked this.

Marcin


On 30 September 2013 18:22, Daniel Roseman <daniel@roseman.org.uk> wrote:
On Monday, 30 September 2013 18:18:00 UTC+1, Zoltan Szalai wrote:
try not to use the same value ('about') for the name attribute of the textarea and your submit button.
not sure it helps the situation though.


I'd say that is the exact cause of the problem, actually.
--
DR. 

--
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+unsubscribe@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/33dbbd77-5726-4a85-b334-02f2041b9b0b%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

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

Re: Vancouver Python Day

That sounds cool, I would consider going if I lived in Vancouver.

On 09/30/2013 03:25 PM, Andy McKay wrote:
The Vancouver Python User Group and the Vancouver Django Meetup Group are pleased to announce:

Vancouver Python Day
Saturday, November 16, 2013
SFU Harbour Centre

Part of Vancouver Developer Week 2013, Vancouver Python Day is a one-day mini conference celebrating the Python Developer Community in Vancouver.

We hope to have talks covering a wide variety of Python development, from web development to gaming to performance and optimization. To that end, we're currently seeking talk proposals. Please visit https://github.com/andymckay/vancouver-python-day and submit your proposal today.

Tickets will be offered for a nominal fee; we'll be sending another announcement before tickets go on sale. In the meantime, please mark your calendars!

More information on Vancouver Python Day:
http://www.vanpyday.com/

More information on Vancouver Developer Week:
http://vancouver.devweek.org/

--
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+unsubscribe@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/CAOjXX8byc%2BVWV6Eu3m_f6ZykPdnF%3Dd7mra4BJkUjdhSy9CDX1g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
--  Mike Doroshenko, Junior Sys Admin  TecKnoQuest Inc.  miked@tecknoquest.com  www.tecknoquest.com

Vancouver Python Day

The Vancouver Python User Group and the Vancouver Django Meetup Group are pleased to announce:

Vancouver Python Day
Saturday, November 16, 2013
SFU Harbour Centre

Part of Vancouver Developer Week 2013, Vancouver Python Day is a one-day mini conference celebrating the Python Developer Community in Vancouver.

We hope to have talks covering a wide variety of Python development, from web development to gaming to performance and optimization. To that end, we're currently seeking talk proposals. Please visit https://github.com/andymckay/vancouver-python-day and submit your proposal today.

Tickets will be offered for a nominal fee; we'll be sending another announcement before tickets go on sale. In the meantime, please mark your calendars!

More information on Vancouver Python Day:
http://www.vanpyday.com/

More information on Vancouver Developer Week:
http://vancouver.devweek.org/

--
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+unsubscribe@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/CAOjXX8byc%2BVWV6Eu3m_f6ZykPdnF%3Dd7mra4BJkUjdhSy9CDX1g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Using unique_together with foreign key fields which may be None

On Mon, Sep 30, 2013 at 4:55 PM, Berndt Jung <berndt@brkt.com> wrote:
Because the lookup_value of a null field is None, the validation check is aborted entirely.  This seems wrong to me, and I'm wondering if I'm doing something wrong here.  Redefining the models is not something I can do at this point.

None in Python corresponds to NULL in SQL. SQL defines that NULL != NULL. So when checking for unique values the database will not consider two NULLs to be the same value; the NULLs will be considered to be different and will not violate the unique constraint. The Django code is doing the same check for uniquess that the database will be enforcing. There is no way I know of to make a database enforce uniqueness among NULL values...


--
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+unsubscribe@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/CACS9raekOZyHHmjEuNRCH-JC9xL7qFqCTuYJbu55pCuONHw-oA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Using unique_together with foreign key fields which may be None

Well, I may have answered my own question.  It looks like per the SQL standard NULL values are unique.  Here from the postgres docs:

In general, a unique constraint is violated when there are two or more rows in the table where the values of all of the columns included in the constraint are equal. However, null values are not considered equal in this comparison. That means even in the presence of a unique constraint it is possible to store duplicate rows that contain a null value in at least one of the constrained columns. This behavior conforms to the SQL standard, but we have heard that other SQL databases may not follow this rule. So be careful when developing applications that are intended to be portable.

So it looks like django is doing the right thing although it seems pretty unintuitive.  It looks like I may have to modify the models afterall.

On Monday, September 30, 2013 1:55:11 PM UTC-7, Berndt Jung wrote:
Hi,

I'm having trouble using the unique together constraint with a a field which may be None.  Given this model:

class Rule(models.Model):

    internal = models.BooleanField(default=False)

    port_range_from = models.PositiveIntegerField(null=True, blank=True)
    port_range_to = models.PositiveIntegerField(null=True, blank=True)

    # either cidr_ip or src_group for ingress rules
    cidr_ip = IPNetworkField(blank=True, null=True)
    is_ingress = models.BooleanField(default=True)

    # a security group is used as src in this rule
    src_security_group = models.ForeignKey(
        SecurityGroup, to_field='uuid', null=True, blank=True)

    class Meta:
        app_label = "nomos"
        unique_together = (
            ('port_range_from', 'port_range_to', 'cidr_ip', 'src_security_group', 'is_ingress'),
        )

Now in this instance src_security_group may be None OR cidr_ip may be None.  In this case they are mutually exclusive.  Regardless I want to use the unique_together to ensure that no two identical rules are created.  However, in the django models/base.py code the following logic is in _perform_unique_check:

lookup_kwargs = {}
            for field_name in unique_check:
                f = self._meta.get_field(field_name)
                lookup_value = getattr(self, f.attname)
                if lookup_value is None:
                    # no value, skip the lookup
                    continue
                if f.primary_key and not self._state.adding:
                    # no need to check for unique primary key when editing
                    continue
                lookup_kwargs[str(field_name)] = lookup_value

            # some fields were skipped, no reason to do the check
            if len(unique_check) != len(lookup_kwargs):
                continue

Because the lookup_value of a null field is None, the validation check is aborted entirely.  This seems wrong to me, and I'm wondering if I'm doing something wrong here.  Redefining the models is not something I can do at this point.

Berndt

--
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+unsubscribe@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/f5710e1c-04ca-4e9c-aa13-0ec756b3a40a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Using unique_together with foreign key fields which may be None

Hi,

I'm having trouble using the unique together constraint with a a field which may be None.  Given this model:

class Rule(models.Model):

    internal = models.BooleanField(default=False)

    port_range_from = models.PositiveIntegerField(null=True, blank=True)
    port_range_to = models.PositiveIntegerField(null=True, blank=True)

    # either cidr_ip or src_group for ingress rules
    cidr_ip = IPNetworkField(blank=True, null=True)
    is_ingress = models.BooleanField(default=True)

    # a security group is used as src in this rule
    src_security_group = models.ForeignKey(
        SecurityGroup, to_field='uuid', null=True, blank=True)

    class Meta:
        app_label = "nomos"
        unique_together = (
            ('port_range_from', 'port_range_to', 'cidr_ip', 'src_security_group', 'is_ingress'),
        )

Now in this instance src_security_group may be None OR cidr_ip may be None.  In this case they are mutually exclusive.  Regardless I want to use the unique_together to ensure that no two identical rules are created.  However, in the django models/base.py code the following logic is in _perform_unique_check:

lookup_kwargs = {}
            for field_name in unique_check:
                f = self._meta.get_field(field_name)
                lookup_value = getattr(self, f.attname)
                if lookup_value is None:
                    # no value, skip the lookup
                    continue
                if f.primary_key and not self._state.adding:
                    # no need to check for unique primary key when editing
                    continue
                lookup_kwargs[str(field_name)] = lookup_value

            # some fields were skipped, no reason to do the check
            if len(unique_check) != len(lookup_kwargs):
                continue

Because the lookup_value of a null field is None, the validation check is aborted entirely.  This seems wrong to me, and I'm wondering if I'm doing something wrong here.  Redefining the models is not something I can do at this point.

Berndt

--
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+unsubscribe@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/fd542fd7-0cd2-40ed-ac3d-e1f3d8a019eb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: How to Query account/profile information for multiple account and allowing user edit or update acount

On Monday, 30 September 2013 19:33:31 UTC+1, Okorie Emmanuel wrote:
I have two problems

1. How can i populate the account
   information of each user, this
   what i have done but only info on
   user models populates, the info on extended
   field does not show on my template

    # models.py
   class Student(Models.model):
          user = foreignkey(user)
          sex= models.charfied()
         ......

     class Teacher(Models.model):
          user = foreignkey(user)
          sex= models.charfied()
          salary models.charfield()
         ......


  
   # views.py
  
 @login_required(login_url='/
login/')
def account(request, template_name="account.html"):
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/login/')
    regis = property(lambda u: Candidate.objects.get(User=u)[0])
    context = {'regis': regis}
    return render_to_response('account.html', context, context_instance=RequestContext(request))
 

What is that property/lambda stuff supposed to be doing? You *seem* to be trying to define something that will get a Candidate from a user, but I don't understand why you're wrapping it in 'property', and then of course you don't ever call it or pass it a User. If you did call it, you'd no doubt get multiple errors, for example `get` only returns a single object so indexing it with [0] is bound to raise an exception.

Also, you might want to explain the relationship between a Candidate and the Student/Teacher models you've shown above. 
--
DR.

--
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+unsubscribe@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/beedfe13-35a8-4def-a0e4-72dc478775fb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: How to Query account/profile information for multiple account and allowing user edit or update acount

Please try, django-userena, or django-registration,
both deal with userdetails.

Thx
Frank


Am 30.09.13 20:33, schrieb Okorie Emmanuel:
I have two problems

1. How can i populate the account
   information of each user, this
   what i have done but only info on
   user models populates, the info on extended
   field does not show on my template

    # models.py
   class Student(Models.model):
          user = foreignkey(user)
          sex= models.charfied()
         ......

     class Teacher(Models.model):
          user = foreignkey(user)
          sex= models.charfied()
          salary models.charfield()
         ......


  
   # views.py
  
 @login_required(login_url='/
login/')
def account(request, template_name="account.html"):
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/login/')
    regis = property(lambda u: Candidate.objects.get(User=u)[0])
    context = {'regis': regis}
    return render_to_response('account.html', context, context_instance=RequestContext(request))
   
    #account.html
   
{% extends "base.html" %}

{% block wrapper %}
<h3> welcome  {{ user.username }}</h3>
<p>Email: {{ user.email }}</p>
<p>Name: {{ regis.u.first_name }}</p>
<p>Sex: {{ regis.sex }}</p>
<p>surname: {{ regis.last_name }}</p>
<p>Date of birth: {{ regis.dob }}</p>
<p>Marital status: {{ regis.marital_status }}</p>
<p>passport: {{ regis.passport }}</p>
<img src="{{ regis.passport.url }}" />

{% endblock %}

{{user.username}}, {{ user.email }} shows but
the rest does not show

2. i Have the profile form to enable user
    edit their account anytime they want,
    but i can't figure the code around it
   
any solution to this problem
thanks
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@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/50bfe62a-556b-4b29-8ba9-50d58006c2c1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

How to Query account/profile information for multiple account and allowing user edit or update acount

I have two problems

1. How can i populate the account
   information of each user, this
   what i have done but only info on
   user models populates, the info on extended
   field does not show on my template

    # models.py
   class Student(Models.model):
          user = foreignkey(user)
          sex= models.charfied()
         ......

     class Teacher(Models.model):
          user = foreignkey(user)
          sex= models.charfied()
          salary models.charfield()
         ......


  
   # views.py
  
 @login_required(login_url='/
login/')
def account(request, template_name="account.html"):
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/login/')
    regis = property(lambda u: Candidate.objects.get(User=u)[0])
    context = {'regis': regis}
    return render_to_response('account.html', context, context_instance=RequestContext(request))
   
    #account.html
   
{% extends "base.html" %}

{% block wrapper %}
<h3> welcome  {{ user.username }}</h3>
<p>Email: {{ user.email }}</p>
<p>Name: {{ regis.u.first_name }}</p>
<p>Sex: {{ regis.sex }}</p>
<p>surname: {{ regis.last_name }}</p>
<p>Date of birth: {{ regis.dob }}</p>
<p>Marital status: {{ regis.marital_status }}</p>
<p>passport: {{ regis.passport }}</p>
<img src="{{ regis.passport.url }}" />

{% endblock %}

{{user.username}}, {{ user.email }} shows but
the rest does not show

2. i Have the profile form to enable user
    edit their account anytime they want,
    but i can't figure the code around it
   
any solution to this problem
thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@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/50bfe62a-556b-4b29-8ba9-50d58006c2c1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Textarea and initial value

On Monday, 30 September 2013 18:18:00 UTC+1, Zoltan Szalai wrote:
try not to use the same value ('about') for the name attribute of the textarea and your submit button.
not sure it helps the situation though.


I'd say that is the exact cause of the problem, actually.
--
DR. 

--
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+unsubscribe@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/33dbbd77-5726-4a85-b334-02f2041b9b0b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Multiple versions of Django

Hi, uwsgi is too good option http://uwsgi-docs.readthedocs.org/en/latest/ and nginx with virtualenv


On Mon, Sep 30, 2013 at 11:45 AM, Peter Herndon <tpherndon@gmail.com> wrote:
I would suggest using separate virtual environments, each with gunicorn (http://gunicorn.org/) installed into the venv. Run gunicorn listening on a different port per venv, start all your venvs under supervisord (http://supervisor.org/), and proxy them behind nginx (http://wiki.nginx.org/).

On Sep 30, 2013, at 11:48 AM, Bill Freeman <ke1g.nh@gmail.com> wrote:

> Virtual environments can, indeed, be used under Apache.  I presume other front ends can also handle this.
>
> For Apache, the separate VE's need to be in separate deamon process groups, so that their sys.path settings can differ.
>
> The primary thing that virtualenv does for you is tweak sys.path, usually by setting PYTHONHOME, but there are other ways.
>
> If using a new enough mod_wsgi (3.4 or later, I htink), there is a python-home option to the WSGIDaemonProcess directive.  Otherwise you can fiddle sys.path in your wsgi script file.  If you are using Apache/mod_wsgi, there is lots of useful documentation and a pointer to their mailing list at http://code.google.com/p/modwsgi/
>
>
> On Mon, Sep 30, 2013 at 11:30 AM, Gerald Klein <jk@zognet.com> wrote:
> Sorry please disregard I didn't read far enough into your message
>
>
> On Mon, Sep 30, 2013 at 10:25 AM, Jasvir Singh <jassigrewal91@gmail.com> wrote:
> Is it possible to install multiple versions of Django on single ubuntu server.
> If yes, please tell me how to do this.
> I have already made a try for this using virtual environment, but
> found that it is only for development.
>
> --
>
> Jasvir Singh Grewal
> Blog:http://jasvirsinghgrewal91.wordpress.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+unsubscribe@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/CAN_O85vhiKvpdxf74stvfR1AsLcoP6E1EeC1M86nHgFRF34K1g%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
> --
> Gerald Klein DBA
> ContactMe@geraldklein.com
> www.geraldklein.com
> geraldklein.wordpress.com
> jk@zognet.com
> 708-599-0352
>
> Arch Awesome, Ranger & Vim the coding triple threat.
> Linux registered user #548580
> Brought to you by the Amish Mafia
>
>
> --
> 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+unsubscribe@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/CAP8NtCw5tr3%3Dt0k6H2CUVGfaNkX6jFhArh6E1iz32s412%3DjL0Q%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@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/CAB%2BAj0trj-MnweyArGTyfSy6SR0wdRLdwV_tYCXfOvA%3DgvOeGg%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@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/78E9816C-7555-4A0C-928D-F9D346463987%40gmail.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+unsubscribe@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/CAM-7rO36Fp4-QFmkq6kpm8Cn__FjZ4%2BbfEZVv3WYuZmPO1WMUw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Multiple versions of Django

I would suggest using separate virtual environments, each with gunicorn (http://gunicorn.org/) installed into the venv. Run gunicorn listening on a different port per venv, start all your venvs under supervisord (http://supervisor.org/), and proxy them behind nginx (http://wiki.nginx.org/).

On Sep 30, 2013, at 11:48 AM, Bill Freeman <ke1g.nh@gmail.com> wrote:

> Virtual environments can, indeed, be used under Apache. I presume other front ends can also handle this.
>
> For Apache, the separate VE's need to be in separate deamon process groups, so that their sys.path settings can differ.
>
> The primary thing that virtualenv does for you is tweak sys.path, usually by setting PYTHONHOME, but there are other ways.
>
> If using a new enough mod_wsgi (3.4 or later, I htink), there is a python-home option to the WSGIDaemonProcess directive. Otherwise you can fiddle sys.path in your wsgi script file. If you are using Apache/mod_wsgi, there is lots of useful documentation and a pointer to their mailing list at http://code.google.com/p/modwsgi/
>
>
> On Mon, Sep 30, 2013 at 11:30 AM, Gerald Klein <jk@zognet.com> wrote:
> Sorry please disregard I didn't read far enough into your message
>
>
> On Mon, Sep 30, 2013 at 10:25 AM, Jasvir Singh <jassigrewal91@gmail.com> wrote:
> Is it possible to install multiple versions of Django on single ubuntu server.
> If yes, please tell me how to do this.
> I have already made a try for this using virtual environment, but
> found that it is only for development.
>
> --
>
> Jasvir Singh Grewal
> Blog:http://jasvirsinghgrewal91.wordpress.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+unsubscribe@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/CAN_O85vhiKvpdxf74stvfR1AsLcoP6E1EeC1M86nHgFRF34K1g%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
> --
> Gerald Klein DBA
> ContactMe@geraldklein.com
> www.geraldklein.com
> geraldklein.wordpress.com
> jk@zognet.com
> 708-599-0352
>
> Arch Awesome, Ranger & Vim the coding triple threat.
> Linux registered user #548580
> Brought to you by the Amish Mafia
>
>
> --
> 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+unsubscribe@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/CAP8NtCw5tr3%3Dt0k6H2CUVGfaNkX6jFhArh6E1iz32s412%3DjL0Q%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@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/CAB%2BAj0trj-MnweyArGTyfSy6SR0wdRLdwV_tYCXfOvA%3DgvOeGg%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@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/78E9816C-7555-4A0C-928D-F9D346463987%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Re: Textarea and initial value

try not to use the same value ('about') for the name attribute of the textarea and your submit button.
not sure it helps the situation though.


On 2013.09.30. 19:13, Marcin Szamotulski wrote:
ps. If I render the form with 
<form action='{{ url('account') }}' method='POST' enctype='multipart/form-data'>
        {{ form.as_ul() }}
</form>
I get the same behaviour.

Marcin


On 30 September 2013 17:11, Marcin Szamotulski <mszamot@gmail.com> wrote:
Sure here it is how the form is render:

 <form action='/account/' method='POST' enctype='multipart/form-data'>
<input type='hidden' name='csrfmiddlewaretoken' value='********************' />
<textarea cols="80" id="id_about" name="about" rows="10">
Submit</textarea>
<div class='errors about_errors'>
</div>
<label for="id_format">Format:</label>
<select id="id_format" name="format">
                <option value="t">Text</option>
                <option value="r" selected="selected">reStructuredText</option>
                <option value="m">MarkDown</option>
        </select>
<div class='errors format_errors'>
</div>
<label for="id_image">Profile image:</label>
<input id="id_image" name="image" type="file" />
<div class='errors image_errors'>
</div>
<input type='submit' name='about' value='Submit'>
    </form>

I use jinja2 template language and it is rendered with
    <form action='{{ url('account') }}' method='POST' enctype='multipart/form-data'>
{% csrf_token %}
{{ render_field(aboutform.about, label=False) }}
{{ render_field(aboutform.format) }}
{{ render_field(aboutform.image) }}
<input type='submit' name='about' value='Submit'>
    </form>

where render_field is a simple macro:

{% macro render_field(field, inline=True, after=True, label=True) -%}
    {% if inline and field.field.widget.__class__.__name__ == 'CheckboxInput' -%}
{{ render_boolfield(field, after) }}
    {%- else -%}
{% if label -%}
{{ field.label_tag() }}
{%- endif %}
{{ field.as_widget() }}
<div class='errors {{field.name}}_errors'>
{{ field.errors.as_ul() }}
</div>
    {%- endif %}
{%- endmacro %}

Thanks,
Marcin



On 30 September 2013 15:11, Daniel Roseman <daniel@roseman.org.uk> wrote:
On Monday, 30 September 2013 15:41:47 UTC+1, Marcin Szamotulski wrote:

I don't do anything odd: I simply modify it by typing in side textarea.
The page has a very simple JavaScript which does not do anything with
the textarea (though I double-checked that turning it off does not
improve the situation).  Inspecting the request reveals that the data is
indeed submitted twice (thus django correctly interpret the situation).

The form is using enctype='multipart/form-data' since it is also used to
submit a file, though leaving only the textarea inside the form and
removing the enctype does not help.

I also checked this in both firefox and chrome and both show that the
POST data for this textarea is submitted twice.

Any ideas?

Thanks for help,
Marcin

Can you perhaps post the template fragment that renders the field, and also the rendered HTML?
--
DR. 


Re: Textarea and initial value

ps. If I render the form with 
<form action='{{ url('account') }}' method='POST' enctype='multipart/form-data'>
        {{ form.as_ul() }}
</form>
I get the same behaviour.

Marcin


On 30 September 2013 17:11, Marcin Szamotulski <mszamot@gmail.com> wrote:
Sure here it is how the form is render:

 <form action='/account/' method='POST' enctype='multipart/form-data'>
<input type='hidden' name='csrfmiddlewaretoken' value='********************' />
<textarea cols="80" id="id_about" name="about" rows="10">
Submit</textarea>
<div class='errors about_errors'>
</div>
<label for="id_format">Format:</label>
<select id="id_format" name="format">
                <option value="t">Text</option>
                <option value="r" selected="selected">reStructuredText</option>
                <option value="m">MarkDown</option>
        </select>
<div class='errors format_errors'>
</div>
<label for="id_image">Profile image:</label>
<input id="id_image" name="image" type="file" />
<div class='errors image_errors'>
</div>
<input type='submit' name='about' value='Submit'>
    </form>

I use jinja2 template language and it is rendered with
    <form action='{{ url('account') }}' method='POST' enctype='multipart/form-data'>
{% csrf_token %}
{{ render_field(aboutform.about, label=False) }}
{{ render_field(aboutform.format) }}
{{ render_field(aboutform.image) }}
<input type='submit' name='about' value='Submit'>
    </form>

where render_field is a simple macro:

{% macro render_field(field, inline=True, after=True, label=True) -%}
    {% if inline and field.field.widget.__class__.__name__ == 'CheckboxInput' -%}
{{ render_boolfield(field, after) }}
    {%- else -%}
{% if label -%}
{{ field.label_tag() }}
{%- endif %}
{{ field.as_widget() }}
<div class='errors {{field.name}}_errors'>
{{ field.errors.as_ul() }}
</div>
    {%- endif %}
{%- endmacro %}

Thanks,
Marcin



On 30 September 2013 15:11, Daniel Roseman <daniel@roseman.org.uk> wrote:
On Monday, 30 September 2013 15:41:47 UTC+1, Marcin Szamotulski wrote:

I don't do anything odd: I simply modify it by typing in side textarea.
The page has a very simple JavaScript which does not do anything with
the textarea (though I double-checked that turning it off does not
improve the situation).  Inspecting the request reveals that the data is
indeed submitted twice (thus django correctly interpret the situation).

The form is using enctype='multipart/form-data' since it is also used to
submit a file, though leaving only the textarea inside the form and
removing the enctype does not help.

I also checked this in both firefox and chrome and both show that the
POST data for this textarea is submitted twice.

Any ideas?

Thanks for help,
Marcin

Can you perhaps post the template fragment that renders the field, and also the rendered HTML?
--
DR. 

--
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+unsubscribe@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/045cca12-7ec5-4d29-bc6c-4a601eff5996%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.


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