Re: How to allow editing m2m relationship with nice widget on both models in admin interface?

2014-09-11 Thread Daniel Oźminkowski
Thanks. I saw it, but thought that there would be a better way to do this. 
because this was asked 2 years ago. I'll give it a tree.
What do you think about splitting models that depend on each another into 
separate apps? Is that the right thing to do?

W dniu środa, 10 września 2014 15:37:15 UTC+2 użytkownik Collin Anderson 
napisał:
>
> There's an ancient ticket about this:
>
> https://code.djangoproject.com/ticket/897
>
> and a workaround on stackoverflow:
>
> http://stackoverflow.com/questions/9879687/adding-a-manytomanywidget-to-the-reverse-of-a-manytomanyfield-in-the-django-admi
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/590f0004-9a06-4c81-a0d4-2144621c3a11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to allow editing m2m relationship with nice widget on both models in admin interface?

2014-09-10 Thread Daniel Oźminkowski
Hello,

I have 2 questions:
1. How in Robot admin page do I limit Applications to only those which
belong to the same Project as Robot?
2. How can I use a better widget in ApplicationInline in Robot page?

Plus if you have any comments on the structure of models, be my guest.

I have following structure of models:

Layout (app):
- Project -< Line -< Robots
Properties (app)
- Application

There is a m2m relation between Robots and Application. I put it on
Application, but maybe it's wrong way to do it. In Pizza-Toppings example
relationship was on Pizzas (
https://docs.djangoproject.com/en/dev/topics/db/models/#many-to-many-relationships
). Is it correct to split my apps like this?

I would like to be able to go to admin interface and:
1. Select Application from Robot page
2. Go to Application page and select which Robots have this application

whichever way feels more comfortable at the moment.

I have it covered from Application side. I have to import models from
layout, so I guess it is a dependency. Then on the other side I import
Application, so is this circular dependency aka "no-no"?

Here's my code:


from django.contrib import admin
from django.contrib import messages

from makrozuli.commissioning.models import Application

import models

class ProjectAdmin(admin.ModelAdmin):
pass

class LineAdmin(admin.ModelAdmin):
pass

class ApplicationInline(admin.StackedInline):
model = Application.robot.through

##def get_queryset(self, request):
##qs = super(ApplicationInline, self).get_queryset(request)
##qs.filter(project= ???

class RobotAdmin(admin.ModelAdmin):
inlines = [ ApplicationInline, ]

admin.site.register(models.Project, ProjectAdmin)
admin.site.register(models.Line, LineAdmin)
admin.site.register(models.Robot, RobotAdmin)
*

The inline can be only Tabular or Stacked. I was looking for something like
filter widget if it is possible. Also I would like to only show Application
which belong only to the Project the Robot belongs to. How do I do it? The
commented part of the code was my attempt to do this, but I'm stuck.

Best regards,
Daniel Ozminkowski

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEW8F8LTCS%3D4oqWDCph2ir5JxfdZjEFsKcFbVeKxf%3D%2BDcKf0BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: /admin redirects me to 127.0.0.1:8000/admin on nginx+gunicorn production server

2014-05-09 Thread Daniel Oźminkowski
Well, the whole description of how the error went away is down there in my
emails.

Try to access the page with curl and/or incognito mode and see what
response you get. Curl is a better choice, because you see all the details
of the response. If you are on Windows and dont have curl, then use Chrome
Developer Tools, they also tell you the details of the request.

Best regards,
Daniel Ozminkowski
9 maj 2014 09:00 "Francisco Roldan" <franciscoprol...@gmail.com> napisał(a):

> Hi!, i have the same issue with nginx. When i try to access to /admin or
> another url without slash o when django redirects, nginx redirect to
> 127.0.0.1/admin.
> How you solved?
>
> Thanks, sorry my english
>
> El jueves, 25 de julio de 2013 06:43:51 UTC-3, Daniel Oźminkowski escribió:
>>
>> I thought that it may be connected to Chrome's Omnibox, but honestly now
>> I can not replicate that behaviour. It works fine in and out of incognito
>> mode.
>>
>> Best regards,
>> Daniel Ozminkowski
>>
>> 2013/7/24 Avraham Serour <tov...@gmail.com>
>>
>>> Well, if it works on incognito mode you should try cleaning your cookies
>>> On Jul 24, 2013 11:33 PM, "Daniel Oźminkowski" <dozmin...@gmail.com>
>>> wrote:
>>>
>>>> Hello again,
>>>>
>>>> I just had a WTF moment. I kept trying to access 192.168.1.4/adminwhich 
>>>> opened
>>>> 0.0.0.0:8000 consistently for the last couple of hours (notice this is
>>>> not localhost). Then I've read somewhere: "check with curl what kind of
>>>> reponse you get directly from gunicorn". So I did and it was fine, I got
>>>> the login form. Then I had a hunch - maybe it's something wrong with my
>>>> browser, Chrome. Turns out I was right - it worked in incognito mode! I
>>>> tried again with normal tab - again 0.0.0.0:8000. So I tried
>>>> http://192.168.1.4/admin/ with the slash at the end and voila! Admin
>>>> login form. Now even without the slash at the end I get the login form
>>>> everytime.
>>>>
>>>> Please, somebody explain this to me. I wasted so much time on this,
>>>> tried so many nginx configurations and I still don't know what I did wrong.
>>>> It's voodoo. ;)
>>>>
>>>> Best regards,
>>>> Daniel Ozminkowski
>>>>
>>>> 2013/7/18 Daniel Oźminkowski <dozmin...@gmail.com>
>>>>
>>>>> Hello,
>>>>>
>>>>> first I want to state, that I am a beginner and everything still works
>>>>> a little like magic for me. I have always worked with django by running it
>>>>> with runserver. Recently decided to put it on virtual machine and serve 
>>>>> the
>>>>> site with nginx + gunicorn. I understand how to serve static files and so
>>>>> on. Even my app works. I hit the problem when I try to access built-in
>>>>> admin interface. Everytime when I go to http://VMip/admin I get
>>>>> redirected to http://127.0.0.1:8000/.
>>>>>
>>>>> I made sure that SITE_ID is the same in settings.py and the
>>>>> django_site table.
>>>>>
>>>>> The server is on a VM, I access it by ip. Here is my nginx config in
>>>>> sites-enabled/my_app.
>>>>>
>>>>> server {
>>>>> server_name 192.168.0.112; # I noticed it doesn't matter. Nginx
>>>>> serves the site even if VM ip changes... hmmm?
>>>>> listen 80;
>>>>>
>>>>> root /home/daniel/www
>>>>> index index.html index.htm
>>>>> client_max_body_size 32M;
>>>>> client_body_buffer_size 128k;
>>>>> location /static/ {
>>>>> root /home/daniel/www
>>>>> }
>>>>>
>>>>> location / {
>>>>> proxy_pass_header Server;
>>>>> proxy_set_header Host $http_host;
>>>>> proxy_redirect off;
>>>>> proxy_set_header X-Real-IP $remote_addr;
>>>>> proxy_set_header X-Scheme $scheme;
>>>>> proxy_connect_timeout 10;
>>>>> proxy_read_timeout 10;
>>>>> proxy_pass http://localhost:8000/;
>>>>> }
>>>>> }
>>>>>
>>>>> I will be very grateful for any clues how to fix it. Thanks!
>>>>>
>>>>> Best regards,
>&g

Circular import problem

2014-04-16 Thread Daniel Oźminkowski
Hello,

I recently cut my models.py into separate files and now I try to fix all
the problems with imports that showed up. I hit the wall on this one though.

Purpose of the application is to process a text file with instructions and
fit them into hierarchical structure like this:

Program <- Node <- Commands

Program has many Nodes, Nodes has many commands.

One of the possible Commands is jumping into subprogram. I want to get url
of that subprogram, so I can show it in a template.

During analysis Program calls Node to create nodes. Node then calls Command
to create Commands.

Then later Command takes the id of the subprogram and call
Program.objects.get().get_absolute_url()

How can I break this import chain?

Best regards,
Daniel

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEW8F8Kv2GJ_f3mvP0mXhhDYj536%2BWwg6YMESd44efBec90Y3w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: /admin redirects me to 127.0.0.1:8000/admin on nginx+gunicorn production server

2013-07-25 Thread Daniel Oźminkowski
I thought that it may be connected to Chrome's Omnibox, but honestly now I
can not replicate that behaviour. It works fine in and out of incognito
mode.

Best regards,
Daniel Ozminkowski

2013/7/24 Avraham Serour <tovm...@gmail.com>

> Well, if it works on incognito mode you should try cleaning your cookies
> On Jul 24, 2013 11:33 PM, "Daniel Oźminkowski" <dozminkow...@gmail.com>
> wrote:
>
>> Hello again,
>>
>> I just had a WTF moment. I kept trying to access 192.168.1.4/admin which
>> opened 0.0.0.0:8000 consistently for the last couple of hours (notice
>> this is not localhost). Then I've read somewhere: "check with curl what
>> kind of reponse you get directly from gunicorn". So I did and it was fine,
>> I got the login form. Then I had a hunch - maybe it's something wrong with
>> my browser, Chrome. Turns out I was right - it worked in incognito mode! I
>> tried again with normal tab - again 0.0.0.0:8000. So I tried
>> http://192.168.1.4/admin/ with the slash at the end and voila! Admin
>> login form. Now even without the slash at the end I get the login form
>> everytime.
>>
>> Please, somebody explain this to me. I wasted so much time on this, tried
>> so many nginx configurations and I still don't know what I did wrong. It's
>> voodoo. ;)
>>
>> Best regards,
>> Daniel Ozminkowski
>>
>> 2013/7/18 Daniel Oźminkowski <dozminkow...@gmail.com>
>>
>>> Hello,
>>>
>>> first I want to state, that I am a beginner and everything still works a
>>> little like magic for me. I have always worked with django by running it
>>> with runserver. Recently decided to put it on virtual machine and serve the
>>> site with nginx + gunicorn. I understand how to serve static files and so
>>> on. Even my app works. I hit the problem when I try to access built-in
>>> admin interface. Everytime when I go to http://VMip/admin I get
>>> redirected to http://127.0.0.1:8000/.
>>>
>>> I made sure that SITE_ID is the same in settings.py and the django_site
>>> table.
>>>
>>> The server is on a VM, I access it by ip. Here is my nginx config in
>>> sites-enabled/my_app.
>>>
>>> server {
>>> server_name 192.168.0.112; # I noticed it doesn't matter. Nginx
>>> serves the site even if VM ip changes... hmmm?
>>> listen 80;
>>>
>>> root /home/daniel/www
>>> index index.html index.htm
>>> client_max_body_size 32M;
>>> client_body_buffer_size 128k;
>>> location /static/ {
>>> root /home/daniel/www
>>> }
>>>
>>> location / {
>>> proxy_pass_header Server;
>>> proxy_set_header Host $http_host;
>>> proxy_redirect off;
>>> proxy_set_header X-Real-IP $remote_addr;
>>> proxy_set_header X-Scheme $scheme;
>>> proxy_connect_timeout 10;
>>> proxy_read_timeout 10;
>>> proxy_pass http://localhost:8000/;
>>> }
>>> }
>>>
>>> I will be very grateful for any clues how to fix it. Thanks!
>>>
>>> Best regards,
>>> Daniel
>>>
>>> --
>>> You received this message because you are subscribed to a topic in the
>>> Google Groups "Django users" group.
>>> To unsubscribe from this topic, visit
>>> https://groups.google.com/d/topic/django-users/ZbtZ9d8YPXo/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to
>>> django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> 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+unsubscr...@googlegroups.com.
>>
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/ZbtZ9d8YPXo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> 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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: /admin redirects me to 127.0.0.1:8000/admin on nginx+gunicorn production server

2013-07-24 Thread Daniel Oźminkowski
Hello again,

I just had a WTF moment. I kept trying to access 192.168.1.4/admin which
opened 0.0.0.0:8000 consistently for the last couple of hours (notice this
is not localhost). Then I've read somewhere: "check with curl what kind of
reponse you get directly from gunicorn". So I did and it was fine, I got
the login form. Then I had a hunch - maybe it's something wrong with my
browser, Chrome. Turns out I was right - it worked in incognito mode! I
tried again with normal tab - again 0.0.0.0:8000. So I tried
http://192.168.1.4/admin/ with the slash at the end and voila! Admin login
form. Now even without the slash at the end I get the login form everytime.

Please, somebody explain this to me. I wasted so much time on this, tried
so many nginx configurations and I still don't know what I did wrong. It's
voodoo. ;)

Best regards,
Daniel Ozminkowski

2013/7/18 Daniel Oźminkowski <dozminkow...@gmail.com>

> Hello,
>
> first I want to state, that I am a beginner and everything still works a
> little like magic for me. I have always worked with django by running it
> with runserver. Recently decided to put it on virtual machine and serve the
> site with nginx + gunicorn. I understand how to serve static files and so
> on. Even my app works. I hit the problem when I try to access built-in
> admin interface. Everytime when I go to http://VMip/admin I get
> redirected to http://127.0.0.1:8000/.
>
> I made sure that SITE_ID is the same in settings.py and the django_site
> table.
>
> The server is on a VM, I access it by ip. Here is my nginx config in
> sites-enabled/my_app.
>
> server {
> server_name 192.168.0.112; # I noticed it doesn't matter. Nginx serves
> the site even if VM ip changes... hmmm?
> listen 80;
>
> root /home/daniel/www
> index index.html index.htm
> client_max_body_size 32M;
> client_body_buffer_size 128k;
> location /static/ {
> root /home/daniel/www
> }
>
> location / {
> proxy_pass_header Server;
> proxy_set_header Host $http_host;
> proxy_redirect off;
> proxy_set_header X-Real-IP $remote_addr;
> proxy_set_header X-Scheme $scheme;
> proxy_connect_timeout 10;
> proxy_read_timeout 10;
> proxy_pass http://localhost:8000/;
> }
> }
>
> I will be very grateful for any clues how to fix it. Thanks!
>
> Best regards,
> Daniel
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/ZbtZ9d8YPXo/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> 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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




/admin redirects me to 127.0.0.1:8000/admin on nginx+gunicorn production server

2013-07-18 Thread Daniel Oźminkowski
Hello,

first I want to state, that I am a beginner and everything still works a 
little like magic for me. I have always worked with django by running it 
with runserver. Recently decided to put it on virtual machine and serve the 
site with nginx + gunicorn. I understand how to serve static files and so 
on. Even my app works. I hit the problem when I try to access built-in 
admin interface. Everytime when I go to http://VMip/admin I get redirected 
to http://127.0.0.1:8000/.

I made sure that SITE_ID is the same in settings.py and the django_site 
table.

The server is on a VM, I access it by ip. Here is my nginx config in 
sites-enabled/my_app.

server {
server_name 192.168.0.112; # I noticed it doesn't matter. Nginx serves 
the site even if VM ip changes... hmmm?
listen 80;

root /home/daniel/www
index index.html index.htm
client_max_body_size 32M;
client_body_buffer_size 128k;
location /static/ {
root /home/daniel/www
}

location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_connect_timeout 10;
proxy_read_timeout 10;
proxy_pass http://localhost:8000/;
}
}

I will be very grateful for any clues how to fix it. Thanks!

Best regards,
Daniel

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django templates

2013-07-17 Thread Daniel Oźminkowski
Hello, 

I am a beginner, but this looks like a job for custom admin command:

https://docs.djangoproject.com/en/1.5//howto/custom-management-commands/

I found it very easy, so it should also be easy for you.

Best regards,
Daniel

W dniu wtorek, 16 lipca 2013 18:43:42 UTC+2 użytkownik Harjot Mann napisał:
>
> In my project the lab reports, reciepts, and bills are made from html 
> templates but thse are not saved anywhere but now I need to take the 
> print outs of all the reports which are made till now for example form 
> job_id 30 to 400. I want to make function for this so that it can be 
> done in a one script. Anyone having idea that how can I do this?/ 
>
> -- 
> Harjot Kaur Mann 
> Blog: http://harjotmann.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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.