Cody Scott | 21 May 2013 21:00
Picon

How to locate django extension templates

I am trying to use django-treebeard in the admin.



It says 

Note

 

If you are going to use the Treeadmin class, you need to add the path to treebeard’s templates in TEMPLATE_DIRS. Also you need to enabledjango.core.context_processors.request in the TEMPLATE_CONTEXT_PROCESSORSsetting in your django settings file.



How do I find where the templates for django-treebeard are located?



--
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 <at> googlegroups.com.
To post to this group, send email to django-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Avraham Serour | 21 May 2013 17:50
Picon
Gravatar

timezone.activate GMT+offset inverts

Hi,

I have created a middleware that calls timezone.activate like this:

from pytz import timezone as tz
timezone.activate(tz('Etc/GMT+3'))

I when printing the time 20:20 UTC+0 it shows as 17:20

I even tried to use

{% timezone "Etc/GMT+3" %}
    {{ value }}
{% endtimezone %}

but it still shows 17:20 when it should show 23:20
of course if I use
{% timezone "Etc/GMT-3" %}
    {{ value }}
{% endtimezone %}

it shows the correct time. is there a bug when using GMT+offset timezone instead of the regular Zone/Country

if anyone is wondering why I am doing this let me try to explain myself.
When a user logs in using facebook I can get the timezone from the extra_data, facebook calculates DST and returns a number

thanks
avraham

--
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 <at> googlegroups.com.
To post to this group, send email to django-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Chris Conover | 21 May 2013 17:23
Picon
Gravatar

Object Lookup after Save

Hello,


I'm having an issue looking up objects immediately after they are saved and am wondering if anyone has any advice on how to address the problem. Specifically, I'm saving an object in a view (nothing fancy, a simple save()) and then kicking off a Gearman task to do some operations on that saved object in the background. I pass the newly created object's PK as data to the Gearman worker which then does a simple Objects.objects.get(pk=PK). However, almost all of the time this lookup operation fails with an DoesNotExist exception. I believe the problem has to do with transactions. Namely, the read in the Gearman worker is happening before the write from the view is committed to the database. I've tried several things including refactoring the saving code to be wrapped in a <at> transaction.commit_on_success block, moving the worker submission to post_save and adding a long delay before the Gearman worker does the lookup. Nothing really seems to solve the problem completely. Even with a 60 second delay, the lookup fails with some frequency. Am I missing something here? Is there some Django query cache that I can clear? Or should I just rewrite all this to just to use a look-back perspective.

The stack is Django 1.4 connecting to MySQL 5.5.27. Django is handling 200-1000 requests per second and the database is handling about double that.

Thanks,
Chris

--
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 <at> googlegroups.com.
To post to this group, send email to django-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Okorie Emmanuel | 21 May 2013 16:03
Picon

problem with extending django registration form

hi

I have tried extending django registration page with little progress.
I can now add new user from the admin but cannot do that on the 
front end. the problem is that the url does not display the from,
but raises exception, "the page cannot be found". Do I need to create a view.py

to be able to use  django registration app?

here is my code

http://pastebin.com/JBa8J1ry

is there anything i have not done right?

--
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 <at> googlegroups.com.
To post to this group, send email to django-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Cody Scott | 21 May 2013 15:14
Picon

How to select a django-treebeard node in a form

I have created my tree structure, now I am trying to create a form that selects a node which I will use to do some operations.


When I render the form 

class SelectNodeForm(MoveNodeForm):

    class Meta:

        model = Category


with {{form.as_p}}


I get the fields


Path

Depth

Numchild

Value

Position

Relative to


I would like the form to just contain relative to (but allow multiple selection)


Looking at the code here it looks like that field is called 

https://github.com/tabo/django-treebeard/blob/master/treebeard/forms.py


_ref_node_id = forms.TypedChoiceField(required=False,
                                          coerce=int,
                                          label=_("Relative to"))

But I cannot render a field that starts with an underscore. "Variables and attributes may not begin with underscores: "

So how can I select a django-treebeard node in a form?



--
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 <at> googlegroups.com.
To post to this group, send email to django-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Nikhil Verma | 21 May 2013 14:56
Picon

access request variable from middlewares into my main project urls

Hello Guys


I want to make the urls dynamic and change according to roles in the project for every app.
Example if there is role x so it should change like x/manage/view_name() , if the role is admin the urls will become  /admin/manage/view_name().

So basically i want to know how can i access request variable from middlewares into my main project urls.
I know how to access template context processors but want  to  learn how to access request in urls.

This is what i have written
 
url_variable = 'corporate'

for app_name in settings.INSTALLED_APPS:
    if not app_name in excluded_apps:
        app = get_app(app_name)

        #-----------------------------------------------------------------------
        # Per module url
        #-----------------------------------------------------------------------
        for model in get_models(app):
            model = model._meta.module_name[5:]
            url_path = r"^manage/%s/?$" % (model.lower())
            view_name = "admin_manage_%s" % (model.lower())
            urlpatterns += patterns('project_name.%s.views' % app_name,
                                      url(url_path, view_name, name=view_name),)

Thanks in advance

--
Regards
Nikhil Verma
+91-958-273-3156

--
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 <at> googlegroups.com.
To post to this group, send email to django-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Joey Espinosa | 21 May 2013 14:29
Picon
Gravatar

Django Celery w/ Amazon RDS and Memcached

Hey guys, I'm having an issue with running Celery on an EC2 instance, using the database transport (django://) and memcached as the cache backend.

I have Celery running via Supervisor, and I can tail the log and see that it's successfully getting a specific task (for reloading the database). However, it never completes, and it just hangs. This exact scenario works perfectly on my own local machine running the same OS, same build of the code, and MySQL 5.5 instead of RDS.

Has anyone else run into similar issues? Note: I can't switch to PostgreSQL (though I'd love to), so I don't have many options in the way of databases. I can always pitch a solution though. Thanks in advance.
--
Joey "JoeLinux" Espinosa

--
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 <at> googlegroups.com.
To post to this group, send email to django-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Thomas Güttler | 21 May 2013 13:26
Picon
Favicon

Deploying CSS/JS with pip

Hi,

I like one part of fanstatic[1]:

You can create dependencies to JS modules. The JS files are available on pypi and this
way installing them is very easy.

example: You can have a requirement on "js.jquery_datatables" in you
requirements.txt file: https://pypi.python.org/pypi/js.jquery_datatables

This makes automated deployment very easy.

There is a django integration, but it looks dead. There was no development
during the last months.

There are some parts of fanstatic which are not need if you use django, but
the js/css packages could be useful for us.

Does anybody use fanstatic together with django?

My goal is to easy the automated deployment.

How do you handle the dependency on external resources like jquery libraries? Do you store
a tgz file inside your source code repository?

Regards,
   Thomas Güttler

[1] http://www.fanstatic.org/en/latest/

--

-- 
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 <at> googlegroups.com.
To post to this group, send email to django-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.

Michael | 21 May 2013 13:23
Favicon
Gravatar

Understanding Django transactions

I've been reading up on how transactions work in Django 1.5 and how they will work in 1.6. I think I have a grasp of things, but I wanted to reach out on here to just check that my understanding of things is correct, and ask a question or two.

Django 1.5:

  • The database-level auto-commit is turned OFF.
  • SQL standards dictate that every query opens a transaction if one does not already exist. This happens regardless of the database's auto-commit setting.
  • After each Django ORM operation (read or write), Django commits this open transaction. This emulates the database-level auto-commit.
  • Transaction decorators cannot be nested. When one is opened, any previous transaction will be committed.
  • When executing raw SQL (with a database cursor), Django marks the current transaction as dirty but does not issue a commit. If data changes were made then they need manually committing. Why do the docs say that you only need to commit the change if data was changed? If the transaction is marked as dirty regardless of a read or a write, would it not always need committing or rolling back to ensure the transaction is properly closed by the end of the connection?
  • Setting TRANSACTIONS_MANAGED to True stops Django from sending any commits after ORM operations. The database-level auto-commit is still disabled. With this setting, using any Django ORM read or write operation (all wrapped in `transaction.commit_on_success`) fails with TransactionManagementError('This code isn't under transaction management'). Is this expected?

Django 1.6:

  • The database-level auto-commit is turned ON.
  • Every database operation via the ORM will be committed using the database's auto-commit, including any custom SQL executed with the database cursor.
  • The `atomic` decorator / context manager either starts a new transaction, or creates a new savepoint if it's nested within an existing transaction. They are committed as long as no exception is raised.
  • If ATOMIC_REQUESTS is specified in the database config, all views are wrapped in `atomic`, unless it's wrapped in `non_atomic_requests`.
  • If you set AUTOCOMMIT to False in a database configuration, this will disable the database-level auto-commit. All DB reads and writes will need manually wrapping in transactions. The docs say that with this disabled, Django won't perform any commits. Does this mean that the `atomic` decorator won't work properly and you have to use the underlying database library to handle transactions? In 1.6 it would appear that Django never performs a commit outside of `atomic`, so I'm confused by this comment!

I'd really appreciate any information if some of what I understand to be true is not accurate.

Many 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 <at> googlegroups.com.
To post to this group, send email to django-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
support | 21 May 2013 05:13
Favicon
Gravatar

Data Access Across Subdomains?

Hello,

I am fairly new to both django, so please excuse this question if there is a doc I missed somewhere that answers it...  Anyhow, I'm planning on moving a large drupal site into django.  Currently the site - yinyanghouse.com - has more or less static content, dynamic community submitted content and some ecommerce functionality.  I'm considering moving the site into three domains to ease some aspects of administration and also give us the future possibilities of moving some parts into other systems - like the static parts into a static site generator and the store into a 3rd party system - for example.

So we would have www.yinyanghouse.com, store.yinyanghouse.com, community.yinyanghouse.com .

Now my question is that we currently have data queries that are important to the site that would then encompass the three subdomains.  I've read a little on the django "sites" framework, but it wasn't clear if you could perhaps share a category between all 3 subdomains, for example, and allow you to display data from one site on another site.  For example, we currently have a "conditions" meta-page say "low back pain" and this pulls in information from all over including related products from our store, related acupuncture points from our static collection of information, etc.  So in that case community.yinyanghouse.com/conditions/low-back-pain would pull in products from store.yinyanghouse.com tagged with "low back pain" in the conditions category as well as acupuncture points from www.yinyanghouse.com tagged with "low back pain".

Is this possible?  Is it too much work for the benefits we would get in clearer layouts between sites, probably better caching prospects, etc.?

Thanks for any ideas/feedback you can offer!
-Chad.

--
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 <at> googlegroups.com.
To post to this group, send email to django-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Christian Schmitt | 21 May 2013 11:27
Picon

Custom RadioSelect() Label from Model Data

Hello, is there a way to get a Custom Label for a RadioSelect() widget?

I have a Model and wanted to get a label like:

'<label for="id_customer_0">
<input type="radio" value="1" name="customer" id="id_customer_0">
{{ customer.name }}
{{ customer.address.city }}
{{ customer.address.zip }}
</label>'

Is there a way to get certain output?
I heard about the RadioSelect Renderer but i can only access the __unicode__ output i definied for the model. Is there a better / other way to implement such functionallity?

--
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 <at> googlegroups.com.
To post to this group, send email to django-users <at> googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Gmane