Sunday, August 31, 2014

Re: Can not add a group to a custom auth user

super(Merchant, self).save(force_insert=True) 

solved the problem!


On Monday, September 1, 2014 2:15:22 PM UTC+8, Ikaros andi wrote:
I debug into save method and find:

ValueError: "<Merchant: m23533>" needs to have a value for field "user" before this many-to-many relationship can be used.

Merchant have already been super saved. I can figure it out




On Wednesday, August 27, 2014 10:08:15 PM UTC+8, Collin Anderson wrote:
i assume "groups" is an editable field in the admin.

after the admin calls merchant.save(), it then clears out and re-assigns the value of groups based on the data in the input field.

--
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/f746f39e-1933-4c64-bc10-f1516da803d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Can not add a group to a custom auth user

I debug into save method and find:

ValueError: "<Merchant: m23533>" needs to have a value for field "user" before this many-to-many relationship can be used.

Merchant have already been super saved. I can figure it out




On Wednesday, August 27, 2014 10:08:15 PM UTC+8, Collin Anderson wrote:
i assume "groups" is an editable field in the admin.

after the admin calls merchant.save(), it then clears out and re-assigns the value of groups based on the data in the input field.

--
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/fcbff67e-a647-4701-9781-f7a860b0b6be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: I have created an app (total noob question)

Hi, Michael--

On Sun, Aug 31, 2014 at 10:28 PM, Michael Carey <mpc.tab4@gmail.com> wrote:
> That is assuming that you just upload the files?

Your doubt is justified. Just uploading the files is a bit of an
oversimplification. It would help if you gave some specifics about the
directory structure you're working with.

However, I can make a few general recommendations ...

1. Are you using version control? If not, you should - and it solves
part of your problem. I know it may seem like overkill to go through
all the steps of setting up a repo for just a little app, but if you
are at all serious about this Django development thing it will save
you a lot of work in the long run. I think these days Git is the most
popular version control system, but Mercurial (AKA hg) and Bazaar (AKA
bzr) are also very good (and both programmed in Python, yay!).

There is a good, concise tutorial online about setting up a Django
project to work with Git. I don't have a link for it, but I found it
very easily by Googling something like "Django version control."

So, assuming you have shell access (e.g., can log in via SSH) on your
web server, you would follow a procedure like this:

git push
DEV MACHINE ------------------> GIT REPOSITORY

git pull
SERVER <------------------ GIT REPOSITORY

That's *very* simplified. In reality, if you are trying to do
professional development, you need to at least have a test environment
online, so that you always test the code in conditions that are as
nearly identical as possible to your production server. But the above
will do if you're just experimenting. And if you don't have shell
access, someone else will have to help you with that.

Now, what files do you put under version control?

Let's say you follow the typical advice, and have a virtual
environment, with any Django projects/sites in separate directories.
For example, I'm using a setup like this (on Linux):

/srv/http/salixmedia.com/test/
pyenv/
[virtual environment with Django and other
required libraries]
my_site/
admin.py
settings.py
local_settings.py
models.py
wsgi.py
....
my_app/
admin.py
models.py
views.py
....

In this setup, all of 'my_app' would go under version control.
Likewise, all of 'my_site' *except* for local_settings.py - or
whichever file contains your secret keys and database password. You
need to guard that information closely, so it should never go into
version control.

Some people think you should put the virtual env (my 'pyenv'
directory) under version control too; I say no. You do want to ensure
that you have all the same libraries installed everywhere, but there's
another way to do that:

$ pip freeze > requirements.txt # on development box

$ pip install -r requirements.txt # on server

The requirements file lists all your installed packages, including
their versions. 'requirements.txt' should be under version control, so
you will have it on your server when you check out the code there. I'm
sure this approach is not totally foolproof, but I believe it is
fairly reliable, and will save you from cluttering your repo with a
great deal of third-party code that you will probably never modify.

Okay, so that takes care of all your python code and config files. You
also have to deal with your database. And honestly, I'm pretty new at
Django myself, and haven't completed figured out this aspect. When you
are setting up a site, you need to use commands such as

python manage.py syncdb

and

python manage.py migrate <app_name>

If you're not familiar with those, I'd suggest you go through the
online documentation. These commands take care of your schemas (to
oversimplify, those represent your models in the database), but they
don't, by default, handle any site content that you may have created.
That's the part I'm not too sure about, but I'm sure others on this
list will have good advice.

Hope that helps a bit.

--
Matt Gushee

--
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/CABrD0eeQoqMcMAiqmmyMgwxMbvZ01rj%2BC%2BkAzepjX%3D8EYDMZxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: I have created an app (total noob question)

On Mon, Sep 1, 2014 at 9:56 AM, Michael Carey <mpc.tab4@gmail.com> wrote:
> ). I cannot work out which files to upload to my website to veiw the page?


Do you mean to deploy on production server?

--
Kamaljeet Kaur

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

Re: I have created an app (total noob question)

That is assuming that you just upload the files?

On Monday, 1 September 2014 14:26:07 UTC+10, Michael Carey wrote:
I have created an app, and it works on the test server (port 8000). I cannot work out which files to upload to my website to veiw the page?

Thank you,

Michael Carey

--
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/ce1f1efb-5cfd-42e9-94fa-eeee25628b30%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

I have created an app (total noob question)

I have created an app, and it works on the test server (port 8000). I cannot work out which files to upload to my website to veiw the page?

Thank you,

Michael Carey

--
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/9639cab8-49e3-414c-a8a9-714940ff7628%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

How create a custom permission for a model?

Hi, how are you?

I have the next question:

Good Nights, this is a question, not a issue.

I need have to user's types: a default admin in django, and a author.
Default admin have a aditional permission: can publish a news.
And for author user i have the next constrains:

  • Can't publish news.
    • Can't create other users
    • Can't create other topics or subtopics
    • Can create a new, but, only can edit or delete his own news, no other user's news.

I talked with other friend and he say me that i need per-objetcs permissions, but, i don't know how do this.

Can you help me?


Now i'm ussing django-permission, but i don't know how do a custom can_publish permission.


I wan't cread a custom view, no, i want used django's admin, news model have a boolean field, is_published, i want that if the user is Author, can modify this field, and if is admin, can modify this field, can anyone help me?

--
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/06752534-dd11-4422-a0cb-25cc81ca077c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: How can I create models which only required during tests in Django 1.7c1?

> Alex
Well as Yo-Yo Ma said, sometime the tests stand for testing django's inner working thus the real models are required.

> Yo-Yo Ma
I haven't tried but thanks for the solution :-)


On Wednesday, July 16, 2014 11:17:56 PM UTC+9, Alisue Lambda wrote:
Hi all. 

Well today I tried Django 1.7c1 with my program and found that the previous testing strategy seems not work.

I have several models which only required during tests. Before Django 1.7, I could create these kind of temporary models by defining these in `app/tests/models.py` with `app_label` specification like this (https://github.com/lambdalisue/django-permission/blob/master/src/permission/tests/models.py). It was quite good strategy for me because I could reduce the dependency of the apps and make the app independent.

But now, it seems Django 1.7c1 cannot find this kind of definitions. I have to add `app.tests` in `INSTALLED_APPS` which was not required before Django 1.7c1.
However, if I add `app.tests` and `app2.tests`, I have to modify `label` of the `app2.tests` because there is already `app_label='tests'` in the registry. It is quite tough job while I have a lot of apps which follow this strategy to test the app.
Additionally, I don't really want to list `app.tests` in my `INSTALLED_APPS` while it is not actually app which required for the site.

So I wonder if there are any better way to define the temporary models. In summary, what I want to do is

1. I want to add temporary models which only required during tests
2. I don't want to mess the db with temporary models (except during tests)

Any idea? Thank you for your cooperation.


Best regard,

--
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/c4ee6dc3-79c5-4222-8309-662aefc1d354%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

How to make a widget with no history?

For example this widget: http://i.imgur.com/ExaZt8l.png

And as you can see there are the history of previous inputs.

And i need to get rid of that.

Meaning: i don't want any history of previous inputs to be displayed.

--
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/1a38b0d7-2201-4d07-a2dc-ef64cef924b0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: response to ajax (jquery) with variables

Thank you Andreas ... I got it !!!

AR

El 30/08/2014 05:04 a.m., Andreas Kuhne escribió:
Hi again Antonio,

First of all, make sure you are using a good browser with debugging capabilities (I prefer Chrome), because you'll need it.

Secondly, I usually use the $.ajax request, instead of the post. Mainly because post is a wrapper around ajax and you can more finely change the settings of ajax.

So the post in your case would be:

$.ajax({
    type: 'POST',               // Make sure you post
    dataType: 'json',          // Use this so that you request json from the server
    url: "/sitioweb/json/",
    data: data,
    success: function(data) {
        // The data that is returned is your json data, already parser, so you don't have to parse it!
        alert(data.array[0]);     // Need to write "array" because that is what you are sending to the browser (your structure looks like that, check what the server is responding with)
    },
    error: function(xhr, textStatus, errorThrown) {
        console.log('AJAX communication failed:', textStatus, errorThrown);    // In case there is an error (for example a 500)
    }
});

Regards,

Andréas

2014-08-30 4:57 GMT+02:00 Antonio Russoniello <arussoni@musicparticles.com>:
Now I can read data from  ajax to my def but I have not idea to how send, for examle, an array to jquery and manage this from javascript...

I tried:

def json_prueba(request):
    arrg = [1,2,3,4]
    if request.method == 'POST':
        return HttpResponse(simplejson.dumps({'array': arrg}), content_type="application/json")
    return HttpResponse('FAIL!!!!!')

from the page side:

    function updateDB(){
        $.post("/sitioweb/json/", data, function(response){
            if(response){
                var data = JSON.parse(response); <--------- NOT SURE IF THIS IS CORRECT
                alert(data[0]); }              <----- I´m trying to put on an alert windows the first item of my array arrg
            else{ alert('Error! :(');}
        });
    }

Thanks in advande.

AR


El 28/08/2014 02:57 a.m., Andreas Kuhne escribió:
Hi Antonio,

import simplejson as json

return HttpResponse(
    json.dumps({
        'array': example
    }),
    content_type="application/json"
)

That would do the trick. This is returned as JSON. Remember to set the content_type, otherwise the client can get confused.

Regards,

Andréas

2014-08-28 2:56 GMT+02:00 Antonio Russoniello <arussoni@musicparticles.com>:
Hello,

i hope you can help me with this, I'm trying to send to an ajax (jquery from my html template) a response but i would like to send also a new variable.

in my html template I have:

    $("#init_date").click(function(){
        var some_date = {'init_date': init_date, 'end_date': end_date};
        $.post("/filter_dates/", some_date, function(response){
            if(response === 'success'){
                MAKE SOMETHING!!!
            else{ alert('error'); }
        });
    });

my django view look like:

def filter_date(request):
    if request.method == 'POST':
        example = ['A','B','C']
        init_date = request.POST['init_date']
        end_date = request.POST['end_date']
         MAKE SOMETHING!!
        return HttpResponse('success') AND HERE I WOULD LIKE TO SEND THE example ARRAY...
    else:
        return HttpResponse('error')

How can I send the array o some other variable as response?

Regards,
AR
--
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/53FE7E44.4020104%40musicparticles.com.
For more options, visit https://groups.google.com/d/optout.

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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+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/54013DA3.3090901%40musicparticles.com.

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

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

Re: how to get a list of all installed applications

On Saturday, August 30, 2014 6:02:57 PM UTC-5, Collin Anderson wrote:
The soon-to-be-released version 1.7 has a documented API for accessing all models and apps:


That's awesome, I'll be on the lookout for it. 

--
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/753906b0-64a7-47b9-bd1a-ef6c560ff6ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Guidance needed - Real time and django

Hello,


2014-08-29 17:26 GMT+02:00 Aamu Padi <aamupadi@gmail.com>:
Hello,
I would like to build a real time web application, but have little idea of where to start to from. It will have notification and feed system like facebook or instagram. Would really appreciate if anyone who have already done this type of web application could kindly guide me through. I will be very grateful.

I never done such things besides small experiments and research...

Here are some pointers:

- search://django+gevent
- search://django+asyncio among other things django-c10k-demo created by Aymeric Augustin django core contributor which use websockets
- search://tornado 
- search://django+SSE
- search://django+webRTC
- search://django+pjax

HTH,

Amirouche

Thank you.

--
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/CAHSNPWuiOJ5m%3DcCUFOc-j%3DRR3LHSAOyhd4Uk7HOaR78cQB-V4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

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

Saturday, August 30, 2014

Re: Change "Add another" text in inline views

Hi Mike,
On 31/08/14 15:46, Mike Dewhirst wrote:
>> i.e. the related object is optional, not provided by default, and at
>> most there can only be one. You'll note that despite max_num being set
>> to 1, it still says "Add//another". Is it possible to delete the word
>> "another" from that text to make it more sensible? (Better yet, can it
>> drop the word "another" when the count currently sits at 0 since
>> "another" implies an object of that type already exists?)
>
> I'm somewhat interested in your success with this because I enjoy it
> when the user interface helps the user understand the software. But I
> think you might have to dig a little deeper for a nice solution.
>
> I found where the Admin has "add another" ...
>
> Searching for: add another
> options.py(945): msg = _('The %(name)s "%(obj)s" was added successfully.
> You may add another %(name)s below.') % msg_dict
> options.py(983): msg = _('The %(name)s "%(obj)s" was changed
> successfully. You may add another %(name)s below.') % msg_dict
> widgets.py(262): % (static('admin/img/icon_addlink.gif'), _('Add
> Another')))
> Found 3 occurrence(s) in 2 file(s)
>
> ... which all looks interesting but maybe too big a job for the
> anticipated benefit.

I'll admit I didn't think to just do a grep of the file structure. When
I do it I get:

> /usr/lib/python2.7/dist-packages/django/contrib/admin/locale/en/LC_MESSAGES/django.po:msgid "Add another %(verbose_name)s"
> /usr/lib/python2.7/dist-packages/django/contrib/admin/templates/admin/edit_inline/tabular.html: addText: "{% blocktrans with inline_admin_formset.opts.verbose_name|capfirst as verbose_name %}Add another {{ verbose_name }}{% endblocktrans %}",
> /usr/lib/python2.7/dist-packages/django/contrib/admin/templates/admin/edit_inline/stacked.html: addText: "{% blocktrans with verbose_name=inline_admin_formset.opts.verbose_name|capfirst %}Add another {{ verbose_name }}{% endblocktrans %}"

The latter two being the HTML templates used for the stacked and tabular
inline widgets. I guess that's a starting point then. :-)

Regards,
--
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
...it's backed up on a tape somewhere.

--
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/5402B8C9.5020606%40longlandclan.yi.org.
For more options, visit https://groups.google.com/d/optout.

Re: Change "Add another" text in inline views

On 31/08/2014 10:05 AM, stuartl@longlandclan.yi.org wrote:
> Hi all,
>
> This is a bit of a silly question, but I wonder if it is possible to
> change the "Add Another" text that appears on inline forms with related
> models. I'm in the process of writing a network configuration module in
> Django that talks with NetworkManager with the intent on using it for
> headless appliances for energy management and possibly SCADA applications.
>
> I have a number of polymorphic models (thank-you django-polymorphic!)
> that describe the various types of network connection, and attached to
> these, are some "settings" objects that describe different aspects of
> the connection. Some of these are one-to-many relationships (e.g. IP
> addresses, routes, DNS servers), but some are one-to-one relationships
> (IPv4/IPv6 options: which specify things like DHCP vs static, 802.1x
> settings, bridge port configuration, etc).
>
> The form at present looks like this:
> http://www.longlandclan.yi.org/~stuartl/images_tmp/django-inlines-add-another.png
>
> Also of note is the capitalisation of some objects, e.g. "Ipv4" instead
> of "IPv4", but I guess I just missed a Meta variable somewhere. I think
> I have seen something that sets this.
>
> For the related objects that are one-to-one, I've defined my admin
> models like so:
>
> |
> classIPv4SettingAdmin(admin.StackedInline):
> model =models.NetIPv4Setting
> extra =0
> min_num =0
> max_num =1
> |
>
> i.e. the related object is optional, not provided by default, and at
> most there can only be one. You'll note that despite max_num being set
> to 1, it still says "Add//another". Is it possible to delete the word
> "another" from that text to make it more sensible? (Better yet, can it
> drop the word "another" when the count currently sits at 0 since
> "another" implies an object of that type already exists?)

I'm somewhat interested in your success with this because I enjoy it
when the user interface helps the user understand the software. But I
think you might have to dig a little deeper for a nice solution.

I found where the Admin has "add another" ...

Searching for: add another
options.py(945): msg = _('The %(name)s "%(obj)s" was added successfully.
You may add another %(name)s below.') % msg_dict
options.py(983): msg = _('The %(name)s "%(obj)s" was changed
successfully. You may add another %(name)s below.') % msg_dict
widgets.py(262): % (static('admin/img/icon_addlink.gif'), _('Add Another')))
Found 3 occurrence(s) in 2 file(s)

... which all looks interesting but maybe too big a job for the
anticipated benefit.

Good luck

Mike


>
> Apologies if this has been asked: I've only seen replies to the question
> of how to remove the "add another" option completely, which isn't what I
> want to do.
>
> Regards,
> Stuart Longland
>
> --
> 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
> <mailto:django-users+unsubscribe@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto: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/9489756e-4813-43cf-8aa8-6cbfedbd87af%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/9489756e-4813-43cf-8aa8-6cbfedbd87af%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+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/5402B69F.6070505%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.

Change "Add another" text in inline views

Hi all,

This is a bit of a silly question, but I wonder if it is possible to change the "Add Another" text that appears on inline forms with related models.  I'm in the process of writing a network configuration module in Django that talks with NetworkManager with the intent on using it for headless appliances for energy management and possibly SCADA applications.

I have a number of polymorphic models (thank-you django-polymorphic!) that describe the various types of network connection, and attached to these, are some "settings" objects that describe different aspects of the connection.  Some of these are one-to-many relationships (e.g. IP addresses, routes, DNS servers), but some are one-to-one relationships (IPv4/IPv6 options: which specify things like DHCP vs static, 802.1x settings, bridge port configuration, etc).

The form at present looks like this: http://www.longlandclan.yi.org/~stuartl/images_tmp/django-inlines-add-another.png

Also of note is the capitalisation of some objects, e.g. "Ipv4" instead of "IPv4", but I guess I just missed a Meta variable somewhere.  I think I have seen something that sets this.

For the related objects that are one-to-one, I've defined my admin models like so:

class IPv4SettingAdmin(admin.StackedInline):
    model
= models.NetIPv4Setting
    extra
= 0
    min_num
= 0
    max_num
= 1

i.e. the related object is optional, not provided by default, and at most there can only be one.  You'll note that despite max_num being set to 1, it still says "Add another".  Is it possible to delete the word "another" from that text to make it more sensible?  (Better yet, can it drop the word "another" when the count currently sits at 0 since "another" implies an object of that type already exists?)

Apologies if this has been asked: I've only seen replies to the question of how to remove the "add another" option completely, which isn't what I want to do.

Regards,
Stuart Longland

--
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/9489756e-4813-43cf-8aa8-6cbfedbd87af%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: how to get a list of all installed applications

The soon-to-be-released version 1.7 has a documented API for accessing all models and apps:

https://docs.djangoproject.com/en/1.7/ref/applications/

--
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/091a7d80-c155-4f7b-8df4-0eaa7ea6790c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Django 1.7 tutorial: Use generic views

I suggest typing:
- manage.py shell
- from polls import views
- dir(views)

What output do you get? i.e, nspect views like the regular python module that it is.


On Sat, Aug 30, 2014 at 6:41 PM, Pitchblack <mikemartin221@gmail.com> wrote:

I need to use Jython instead of Python, I found that jython2.7b2 works with DJango 1.7. So, I am stuck using the beta version. I am trying to follow the current Django tutorial and I have ran into a problem. I am not sure if I am using generic views properly. When I try to change the urls.py (polls) file. I see that pydev complains that views.IndexView, views.DetailView, and ResultsView don't exist. Am I doing something wrong? Or did they change the way generics work in version 1.7?

My System:

  • Windows 7
  • jython2.7b2
  • Django-1.7c3
  • postgresql-9.3.5-1-windows-x64
  • postgresql-9.3-1102.jdbc41.jar

Here is the url for the tutorial, go to the section "Use generic views: Less code is better"
https://docs.djangoproject.com/en/dev/intro/tutorial04/


--
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/5be54cfd-ed53-40ca-b7e1-297814c1727d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Regards,
Sithu Lloyd Dube

--
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/CAH-SnCBTSo-C_99JOZuu4fZd3Uyc_UyOU5JEW%2BPYDqdJMYhYag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Re: Django admin can't display user detail view: 500 error

Okay, I got everything working. I was totally over thinking things I think. I added the ADMINS variable in my settings to get a traceback and it seems a package(django-tastypie) I installed on my development side I forgot to install on the production side. Once I installed it, I migrated it's new tables using South and everything worked.

On Thursday, August 28, 2014 8:22:00 PM UTC-4, amarshall wrote:
I've deployed my django application using Nginx and uWSGI.

In development I can login to my django admin-> users-> [username] and it shows the users information. However in development once I click on a user I get a "server 500" error. I have the same code for both deployment and development. I can't think of what the problem could be ?

--
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/bb542db8-0dad-44fc-995d-3443afad9070%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: how to get a list of all installed applications



On Sunday, May 20, 2007 11:51:49 AM UTC-5, Malcolm Tredinnick wrote:

Have a look in django/db/models/loading.py . There are a number of
useful methods in there. In particular, get_apps(), which contrary to
what you claim above, should give you all installed apps, not installed
models (you use get_models(app_name) to get all the models for an app).

Regards,
Malcolm


Hello, this is a very old post but seeing how I got here from a Google search I figure someone else might also. Looking at get_apps() this is what I get:

from django.db.models import loading
   
for mod in loading.get_apps():
       
print(mod.__name__)


And the output:
django.contrib.auth.models
django
.contrib.contenttypes.models
django
.contrib.sessions.models
django
.contrib.sites.models
django
.contrib.messages.models
django
.contrib.staticfiles.models
django
.contrib.admin.models
django
.contrib.admindocs.models
debug_toolbar
.models
django_extensions
.models
solo
.models
wp_user_agents
.models
home
.models
projects
.models
# <...plus all of my other app's models...>


So you see, get_apps() does return the models, not the apps themselves.

However, I did find this that works:
from django.conf import settings
from django.utils.module_loading import import_module
apps
= []
for appname in settings.INSTALLED_APPS:
    apps
.append(import_module(appname))


Or to shorten it:
from django.conf import settings
from django.utils.module_loading import import_module
apps
= [import_module(appname) for appname in settings.INSTALLED_APPS]


I needed it to design a search app for my site. If anyone has a better way I would really like to hear about it (no sarcasm).




--
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/ee48eaaa-a507-4d54-a6ef-d3fa57503234%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

How to insert an inline in admin with the simple model without fk?


    class Infos(Model):

    created = DateTimeField(auto_now_add=True)
   modified = DateTimeField(auto_now=True)

    name = CharField(max_length=255, blank=False, null=False)

    phone = CharField(max_length=255, blank=False, null=False)
    address
= CharField(max_length=255, blank=False, null=False)

And back in the admin list display the saved objects.
I appreciate the help!

--
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/84054c45-79c1-41fe-b963-8faba748e833%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Django 1.7 tutorial: Use generic views

I need to use Jython instead of Python, I found that jython2.7b2 works with DJango 1.7. So, I am stuck using the beta version. I am trying to follow the current Django tutorial and I have ran into a problem. I am not sure if I am using generic views properly. When I try to change the urls.py (polls) file. I see that pydev complains that views.IndexView, views.DetailView, and ResultsView don't exist. Am I doing something wrong? Or did they change the way generics work in version 1.7?

My System:

  • Windows 7
  • jython2.7b2
  • Django-1.7c3
  • postgresql-9.3.5-1-windows-x64
  • postgresql-9.3-1102.jdbc41.jar

Here is the url for the tutorial, go to the section "Use generic views: Less code is better"
https://docs.djangoproject.com/en/dev/intro/tutorial04/


--
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/5be54cfd-ed53-40ca-b7e1-297814c1727d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.