Re: Persist shopping cart data between computers.

2015-03-17 Thread mail4dk
Do I need to code this logic by myself or is there a build in mechanism or 
plugin that will allow me to have it like the shopping cart plugins 
available online that store the data in the session collection?

On Sunday, March 15, 2015 at 4:45:38 PM UTC+2, Avraham Serour wrote:
>
> save it on the database, when the user logs in from another computer he 
> will have another session associated with the same user
> the user have the shopping cart saved on the DB
>
> On Sun, Mar 15, 2015 at 10:06 AM, > wrote:
>
>> Hello,
>>
>> I'm using an old version of Django (1.5, I know its old and problematic 
>> but currently I'm unable to upgrade).
>>
>> To my understanding sessions are identified by a key saved in a cookie on 
>> the client's computer and so the session persists only for the next login 
>> from the same computer and from he same browser and I would like to know if 
>> there is a known plugin or middlewear that allows me to persist a session 
>> between computers.
>>
>> The bigger picture is that i'm interesting in saving a shopping cart like 
>> object that will presist for the user when he logs in from different 
>> computers and most of the plugins that manage shopping carts in Django I've 
>> seen manage those in the user session.
>>
>> I'm looking for the simplest way of adding this functionality without 
>> changing too much code.
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/51fc87f3-e29a-4249-bf3f-caa3369bcf5a%40googlegroups.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+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/734cea70-f4e2-4f2d-ba63-e0a7462ed0f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Invalid HTTP_HOST, can someone explain why I am getting this?

2015-03-17 Thread Russell Keith-Magee
Hi,

It's possible that you're getting this error for the exact reason that the
check was added - someone is submitting requests to your site with a
manipulated HTTP_HOST header. This may not be malicious - it could just be
a badly configured robot making web requests.

It might also point at a problem with your hosting provider - especially if
you're sharing an IP address with g3suprimentos.com.br, or if
g3suprimentos.com.br once had the same IP that you're currently using.

Without more details, it's hard to say for certain. But is someone trying
to hack your site? Almost certainly not. If you were being hacked, you
wouldn't have described the problem as "I see this error from time to time"
- you would have said "I just received a thousand of these in the last 10
minutes". Attackers aren't noted for their subtlety - they will generally
try every possible backdoor and exploit that they know of, all at once.

Yours,
Russ Magee %-)

On Tue, Mar 17, 2015 at 11:45 PM, frocco  wrote:

> I am concerned because I have a value in ALLOWED_HOSTS, but it is not this
> value.
>
>
> On Tuesday, March 17, 2015 at 9:17:15 AM UTC-4, frocco wrote:
>>
>> SuspiciousOperation: Invalid HTTP_HOST header (you may need to set
>> ALLOWED_HOSTS): www.g3suprimentos.com.br
>>
>> I keep getting this error from time to time.
>>
>> Is someone trying to hack my site?
>>
>> 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+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/5550dde0-4230-4068-a8b5-196f0bd844fc%40googlegroups.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+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/CAJxq849VOSnDfv3WCQhBtHTC41ANiLPR9C3TenYub3yh4Nxf2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django phonegap CORS

2015-03-17 Thread Filipe Ximenes
Hey, I wrote a blog post about CORS and Django with more details about the
subject:
http://www.vinta.com.br/blog/2015/django-cors.html

=)

On Fri, Mar 13, 2015 at 5:32 PM, Filipe Ximenes 
wrote:

> Alright, I think I got what you want now.
>
> The first solution that comes to mind is to perform everything in the
> browser. That way, you will first perform "window.open()" and then show a
> "login view" from django server.
>
> I don't have any experience with Phonegap, but it seems that this can also
> help you:
>
> http://docs.phonegap.com/en/edge/cordova_inappbrowser_inappbrowser.md.html#addEventListener
>
> Maybe if you attach a "loadstart" event to the browser and save user
> credentials to "localStorage" or a cookie, using the method described here:
>
> http://blogs.telerik.com/appbuilder/posts/13-12-23/cross-window-communication-with-cordova's-inappbrowser
>
> Since everything will be working in a common browser application (not a
> single page application, or phonegap app), I'd suggest you to work with
> default Django cookie session and not with a token based authentication.
> This will be simpler since once you set the cookie, the browser will take
> care off passing it over page requests and you will not need to make
> customisations to your Django views regarding authentication.
>
> On Fri, Mar 13, 2015 at 4:53 PM, Florian Auer  wrote:
>
>> Hello Filipe
>>
>> Thank you for the reply.
>> Well the $http object was till now unknown for me.. there we can see how
>> poor my AngularJS knowledge is till now.
>>
>> But as far as i understood the documentation i am not able to bring up a
>> browser window by this that takes over the control of the app.
>>
>>
>> The idea behind all is the following, maybe i did not describe it well.
>>
>> The App is only thought a a "startUp wrapper" with stored credentials in
>> form of a login token.
>> That token is claimed in a first asynchronous request with user
>> credentials asked for interactively.
>> Later on when the token is known, the app only sets the headers an calls
>> the django web page where the user gets logged in due the header
>> automatically.
>>
>> At the moment I was using the JWT (
>> http://getblimp.github.io/django-rest-framework-jwt/) to claim a token.
>> But i do not know how to use this to let the user been logged in with the
>> call of a browser window.
>> Maybe I need tho turn over to TokenBasedAuthentification like described
>> in (
>> http://www.django-rest-framework.org/api-guide/authentication/#tokenauthentication
>> )?
>> But then I will still have the same problem... How to bring the token
>> into the headers and thenn call a page from the server rendered inside the
>> browser in UI mode (not in the app as sub page)
>>
>> My idea was, that an phonegap app is nothing more than a browser rendered
>> app.
>> When I can create a request to a server to claim an Auth Token and be
>> able to set this into the headers, the next Ui request to the server
>> (launching another browser window by window.open()) will let me call
>> directly to a restricted view.
>>
>>
>>  --
>> 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/db6f6050-b1b9-4ea4-9729-94a3184c5e82%40googlegroups.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>
>
> *Filipe Ximenes*+55 (81) 8245-9204
>
> *Vinta Software Studio*http://www.vinta.com.br
>



-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
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/CAA-QWB3vtvnHbmgfZWGOefLMgkbH0SyqAEZ3VZgGaYRdoNRCUw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Testing template context processors

2015-03-17 Thread Gergely Polonkai
Hello,

My processor sets some template variables based on request.user and some
DB/redis query results, which are displayed on each page on a header bar,
so I only need to create a mocked request with user set to something
(AnonymousUser or a valid user object).

I'm already using Mock[2] for middleware testing, funny that I didn't think
of this way (especially as I implemented it today), so thanks for pointing
out!

[2] https://pypi.python.org/pypi/mock
On 17 Mar 2015 17:59, "Carl Meyer"  wrote:

> Hi Gergely,
>
> On 03/17/2015 10:52 AM, Gergely Polonkai wrote:
> > I wrote a context processor which makes some global variables of mine
> > available for templates. I cannot find a good (cough… any) article on
> > how to test such processors. Could you give me some directions on where
> > to start with writing one?
>
> Writing a unit test for a context processor is quite simple. Construct a
> fake request (you can use RequestFactory, though if your context
> processor only accesses one or two attributes of the request, it might
> be simpler to just build a custom fake or use a library like pretend
> [1]), then call the context processor function in your test, passing in
> the fake request, and assert that the returned dictionary contains what
> you expect.
>
> If your templates require the values from the context processor in order
> to render correctly, you can also write a higher-level integration or
> functional test by using the test client to access a view that renders a
> template that needs the context processor, and then assert the right
> value is found in the rendered HTML.
>
> Carl
>
>   [1] https://pypi.python.org/pypi/pretend
>
> --
> 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/55085D7A.5040007%40oddbird.net
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: implementing dynamic models

2015-03-17 Thread Guilherme Leal
I came up with the same conclusion.

Em ter, 17 de mar de 2015 10:56, Django User 
escreveu:

> yes, i did. however, none of those approaches look compelling for a
> production system.
>
>
> On Tuesday, March 17, 2015 at 6:06:11 PM UTC+5:30, Guilherme Leal wrote:
>
>> did you looked into some of these
>> 
>> aproaches?
>>
>> Em ter, 17 de mar de 2015 às 09:07, Guilherme Leal 
>> escreveu:
>>
>>> I REALLY would appreciate some feature like this. If some
>>> developer/engeneer has implemented something like it, please share your
>>> knowledge.
>>>
>>> The first thing i  would test, is to save the model in a .py file (i
>>> think that saving the model might be important for the performance, since
>>> the python interpreter will compile it and stuff), and in some way reload
>>> de app  (since the models are registered on the app during the
>>> configuration step of the app).
>>>
>>> Not sure if this would work though...
>>>
>>> Em ter, 17 de mar de 2015 às 08:27, Django User 
>>> escreveu:
>>>
>>> hello,
 we are working on an application where users can register new types of
 data streams through Django. so it requires a mechanism to create new
 tables (cassandra) on the fly. what is the best Djangoish way to implement
 such dynamic models? pls. let us know. thanks in advance.

 --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.

>>> To unsubscribe from this group and stop receiving emails from it, send
 an email to django-users...@googlegroups.com.
 To post to this group, send email to django...@googlegroups.com.
>>>
>>>
 Visit this group at http://groups.google.com/group/django-users.
 To view this discussion on the web visit https://groups.google.com/d/ms
 gid/django-users/59af92ca-940f-40a8-8518-34d33ccce00e%40goog
 legroups.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+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/8746285c-ce5d-4c01-8dc4-02c12fe299df%40googlegroups.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+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/CAOs3Lp6As0Hy3wkCTdpU8zGm6XCQKrU5diqV%2BwSDroaF8zHdXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: forms of 2 tables upload files

2015-03-17 Thread Filipe Ximenes
You can keep the ModelForm just like the tutorial and override the "save"
method.
It will look something like this:

class MyForm(forms.ModelForm):
the_file = forms.FileField(required=True)

class Meta:
model = Person
fields = ('name', 'email', 'the_file')

def save(self, commit=True):
person = super(MyForm, self).save(commit)

file_instance = FileModel(the_file=self.cleaned_data['the_file'])

if commit:
file_instance.save()

return person
-- 


*Filipe Ximenes*+55 (81) 8245-9204

*Vinta Software Studio*http://www.vinta.com.br

-- 
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/CAA-QWB3fFrOiU7yDtnEcPo33SmrNCSUSNX3%3DNZOLmi-WHQf2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Testing template context processors

2015-03-17 Thread Carl Meyer
Hi Gergely,

On 03/17/2015 10:52 AM, Gergely Polonkai wrote:
> I wrote a context processor which makes some global variables of mine
> available for templates. I cannot find a good (cough… any) article on
> how to test such processors. Could you give me some directions on where
> to start with writing one?

Writing a unit test for a context processor is quite simple. Construct a
fake request (you can use RequestFactory, though if your context
processor only accesses one or two attributes of the request, it might
be simpler to just build a custom fake or use a library like pretend
[1]), then call the context processor function in your test, passing in
the fake request, and assert that the returned dictionary contains what
you expect.

If your templates require the values from the context processor in order
to render correctly, you can also write a higher-level integration or
functional test by using the test client to access a view that renders a
template that needs the context processor, and then assert the right
value is found in the rendered HTML.

Carl

  [1] https://pypi.python.org/pypi/pretend

-- 
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/55085D7A.5040007%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: OpenPGP digital signature


Testing template context processors

2015-03-17 Thread Gergely Polonkai
Hello,

I wrote a context processor which makes some global variables of mine
available for templates. I cannot find a good (cough… any) article on how
to test such processors. Could you give me some directions on where to
start with writing one?

Thanks in advance!

Best,
Gergely

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


Uncaught TypeError: Cannot read property 'value' of null

2015-03-17 Thread elcaiaimar
Hello

I wonder if somebody knows how to solve the next:

I want to send a value from the template to a script and it seems it works 
but I get an error: Uncaught TypeError: Cannot read property 'value' of null

Below it is my code:

*Template:*



{{ obra.id }} is an object sended from views.py

*Javascript:*

var idobra = document.getElementById("idobra").value;
console.log(idobra);

And I don't know what I'm doing wrong. I would like to know if there is 
another way to send objects directly from django to javascript or if I'm 
doing well like that, but solving the problem.

Thank you very much!

-- 
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/81b65371-ce65-40e2-94ff-a876a24f6a86%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Invalid HTTP_HOST, can someone explain why I am getting this?

2015-03-17 Thread frocco
I am concerned because I have a value in ALLOWED_HOSTS, but it is not this 
value.


On Tuesday, March 17, 2015 at 9:17:15 AM UTC-4, frocco wrote:
>
> SuspiciousOperation: Invalid HTTP_HOST header (you may need to set 
> ALLOWED_HOSTS): www.g3suprimentos.com.br
>
> I keep getting this error from time to time.
>
> Is someone trying to hack my site?
>
> 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+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/5550dde0-4230-4068-a8b5-196f0bd844fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Invalid HTTP_HOST, can someone explain why I am getting this?

2015-03-17 Thread Eric Davis
What is the value of ALLOWED_HOSTS in settings.py?

Your site is serving requests that contain a "Host: 
www.g3suprimentos.com.br" header. Django 
doesn't recognize this as an allowed host, hence the error.

https://docs.djangoproject.com/en/1.7/ref/settings/#allowed-hosts has more.

Eric Davis
Email: eda...@eresources.com
Skype: edavis215

On Mar 17, 2015, at 6:17 AM, frocco 
mailto:faro...@gmail.com>> wrote:

SuspiciousOperation: Invalid HTTP_HOST header (you may need to set 
ALLOWED_HOSTS): www.g3suprimentos.com.br

I keep getting this error from time to time.

Is someone trying to hack my site?

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+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/1aa55c70-e51b-44f0-aae6-d1ca3e666467%40googlegroups.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+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/0A0A953B-A33B-4148-88A1-83FB706AEB40%40eresources.com.
For more options, visit https://groups.google.com/d/optout.


forms of 2 tables upload files

2015-03-17 Thread dk
i have 2 tables,   1 table contain the fields for name, email, 
and I did another table with file, and date.

and I am trying to populate the 2 tables when a user submit the form.

I follow this amazing tutorial
https://amatellanes.wordpress.com/2013/11/05/dropzonejs-django-how-to-build-a-file-upload-form/
  

but he is using the trick of using the models to do the form.   witch you 
can only use one table for that.

in the mean time we change the code and we are using just 1 table, with 
name email, file and date and then doing it exactly like the tutorial, 
and my view is like this

def request_page(request):
   if request.method == "POST":
  form = Submit_Form(request.POST, request.FILES)
  if form.is_valid():
 email = form.cleaned_data["email"]
 per = Person(email=email, date=datetime.datetime.now(), 
file=request.FILES['file'])
 per.save()

 message = "Thanks, Submission accepted:" + email
 forma = Submit_Form()
 # return redirect("request_page", {"form": forma, "message": message})
 return render(request, "submit_request.html", {"form": forma, 
"message": message})
   else:
  form = Submit_Form()

   return render(request, "submit_request.html", {"form": form, "message": ""})





I can make my own form  like this

# class NameForm(forms.Form):
# name = forms.CharField(label='Name', max_length=100, required=True, 
initial="")
# last_name = forms.CharField(label='Last Name', max_length=100, 
required=True, initial="")
# email = forms.EmailField(label="Email", required=True, initial="")


# the_file = forms.FileField(required=True)

# date = forms.DateTimeField()



will render properly but later on I don't know how to populate the 2 tables.   

any one have a little example that I can follow to .save() the person table and 
the file table?


thank you guys. =)

-- 
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/65a0f26c-9f07-499c-88eb-fd625e6d34c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: implementing dynamic models

2015-03-17 Thread Django User
yes, i did. however, none of those approaches look compelling for a 
production system.

On Tuesday, March 17, 2015 at 6:06:11 PM UTC+5:30, Guilherme Leal wrote:
>
> did you looked into some of these 
> 
>  
> aproaches?
>
> Em ter, 17 de mar de 2015 às 09:07, Guilherme Leal  > escreveu:
>
>> I REALLY would appreciate some feature like this. If some 
>> developer/engeneer has implemented something like it, please share your 
>> knowledge.
>>
>> The first thing i  would test, is to save the model in a .py file (i 
>> think that saving the model might be important for the performance, since 
>> the python interpreter will compile it and stuff), and in some way reload 
>> de app  (since the models are registered on the app during the 
>> configuration step of the app).
>>
>> Not sure if this would work though...
>>
>> Em ter, 17 de mar de 2015 às 08:27, Django User > > escreveu:
>>
>> hello,
>>> we are working on an application where users can register new types of 
>>> data streams through Django. so it requires a mechanism to create new 
>>> tables (cassandra) on the fly. what is the best Djangoish way to implement 
>>> such dynamic models? pls. let us know. thanks in advance. 
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-users...@googlegroups.com .
>>> To post to this group, send email to django...@googlegroups.com 
>>> .
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/django-users/59af92ca-940f-40a8-8518-34d33ccce00e%
>>> 40googlegroups.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+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/8746285c-ce5d-4c01-8dc4-02c12fe299df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Reload App

2015-03-17 Thread Guilherme Leal
Is there a way to "reload" a django app?
What i need is basically, re-run the Apps.populate, to trigger the discover
of new apps and models.

and now you're asking "What would he want this?".

Basically, i'm trying to create a feature where the users of my project
(who also will be devellopers) can create apps and models on the fly. Also,
i checked for the EAV and Dynamo implementations, and particularly didn't
liked neither at all (saving the model config on DB dont seems to be fast
enough to any production app, specially if you're especting to have
hundreds of models).

Any help/advice would be apreciated.
Thx in advance!

-- 
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/CAOs3Lp5ossyVvK%3DfrM1S602XtC%2BccPF_jjG%3DjO4RbZN7RG%3D3Og%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Invalid HTTP_HOST, can someone explain why I am getting this?

2015-03-17 Thread frocco
SuspiciousOperation: Invalid HTTP_HOST header (you may need to set 
ALLOWED_HOSTS): www.g3suprimentos.com.br

I keep getting this error from time to time.

Is someone trying to hack my site?

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+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/1aa55c70-e51b-44f0-aae6-d1ca3e666467%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: implementing dynamic models

2015-03-17 Thread Guilherme Leal
did you looked into some of these

aproaches?

Em ter, 17 de mar de 2015 às 09:07, Guilherme Leal 
escreveu:

> I REALLY would appreciate some feature like this. If some
> developer/engeneer has implemented something like it, please share your
> knowledge.
>
> The first thing i  would test, is to save the model in a .py file (i think
> that saving the model might be important for the performance, since the
> python interpreter will compile it and stuff), and in some way reload de
> app  (since the models are registered on the app during the configuration
> step of the app).
>
> Not sure if this would work though...
>
> Em ter, 17 de mar de 2015 às 08:27, Django User 
> escreveu:
>
> hello,
>> we are working on an application where users can register new types of
>> data streams through Django. so it requires a mechanism to create new
>> tables (cassandra) on the fly. what is the best Djangoish way to implement
>> such dynamic models? pls. let us know. thanks in advance.
>>
>> --
>> 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/59af92ca-940f-40a8-8518-34d33ccce00e%
>> 40googlegroups.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+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/CAOs3Lp6x-aFwtHJDr7_mp%2BFqG9X4jL%3D4GWganAkSO-T2bMQybA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: implementing dynamic models

2015-03-17 Thread Guilherme Leal
I REALLY would appreciate some feature like this. If some
developer/engeneer has implemented something like it, please share your
knowledge.

The first thing i  would test, is to save the model in a .py file (i think
that saving the model might be important for the performance, since the
python interpreter will compile it and stuff), and in some way reload de
app  (since the models are registered on the app during the configuration
step of the app).

Not sure if this would work though...

Em ter, 17 de mar de 2015 às 08:27, Django User 
escreveu:

> hello,
> we are working on an application where users can register new types of
> data streams through Django. so it requires a mechanism to create new
> tables (cassandra) on the fly. what is the best Djangoish way to implement
> such dynamic models? pls. let us know. thanks in advance.
>
> --
> 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/59af92ca-940f-40a8-8518-34d33ccce00e%40googlegroups.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+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/CAOs3Lp5Oh0Nd5OEFgECswZmwXwr5_vXZdfjW0cBCET2jTYotzQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


implementing dynamic models

2015-03-17 Thread Django User
hello,
we are working on an application where users can register new types of data 
streams through Django. so it requires a mechanism to create new tables 
(cassandra) on the fly. what is the best Djangoish way to implement such 
dynamic models? pls. let us know. thanks in advance. 

-- 
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/59af92ca-940f-40a8-8518-34d33ccce00e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Authentication Layer

2015-03-17 Thread Satya Dev
Hi , I have been working on Django for a few days and have been trying to 
implement a login page for the website similar to the login page of the 
admin interface.
 
I have created an auth.html which asks for a username and password and have 
given the necessary links in views.py and urls.py
 
I get the login page when I go to my RootURL but when I login , it just 
displays a blank page. I have set the form action in auth.html to 
RootURL/ABC but instead of loading RootURL/ABC, it loads a blank page.
 
I need the user to enter credentials if he wants to access the website , is 
there any other easy way to do this where I could configure the website to 
ask for credentials when I want to access it.
 
I also looked at https://docs.djangoproject.com/en/1.7/topics/auth/default/ and 
the login_required functionality but I am unable to implement this. What am 
I missing ?
 
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+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/02bbc3c5-7330-4d1b-a19f-ac5bf3725873%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django beggining problems

2015-03-17 Thread Sergiy Khohlov
Answer is simple. Notepad opens python files.. Try to start python.exe
djangoadmin
 13 бер. 2015 18:55, користувач  написав:

> i am following the tutorial right now...
> I use windows 7
>  python 2.7.6
> and  django 1.7.6
>
> when i run "django-admin startproject mysite"
>
> it opens a file on notepad++ called django-admin with some code in it
>
>
> #!c:\users\radcliff\appdata\local\enthought\canopy32\user\scripts\python.exe
> from django.core import management
>
> if __name__ == "__main__":
> management.execute_from_command_line()
>
> and no folder or file have been created.
>
> have i done something wrong?
>
> --
> 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/217b9837-c580-433a-adff-98066624e967%40googlegroups.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+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/CADTRxJN6LRzA%2B2t3_rSd8Yyg3OxbdtnhVwY1g9--kGQiCZ0rYQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Changing table name in response to a QuerySet

2015-03-17 Thread James Schneider
That sounds more like an exact use case for model inheritance. You would
define a single model that matches the columns in both tables. You can
define that model as abstract, then have the two real models (one for each
table) inherit from that abstract model. In the definition for the child
models, you would specify the DB table names to match your two tables in
the existing schema.

https://docs.djangoproject.com/en/1.7/ref/models/options/#db-table

That way, you only maintain a single (abstract) model definition, even
though multiple models use it (each with a separate DB table).

You may also need to mark the real models as unmanaged by the ORM if you're
doing funny things directly in the DB, and you will be managing the table
schema directly for those tables.

https://docs.djangoproject.com/en/1.7/ref/models/options/#managed

I'm assuming you have already determined the logic deciding which model
each user uses. At that point, assuming that all other functionality
remains the same (calls/processing the data, regardless of table), the
calls to those models can be generalized by a simple utility function that
returns a class instance of the necessary model.

def get_right_model(user):
# logic to pick ModelA or ModelB based on user
return ModelA

Then later, maybe in a view:

selected_model = get_right_model(self.request.user)

all_data = selected_model.objects.all()

#all_data should now contain the results of the query against the right
model/table in the DB

Trying to flip between tables in the ORM by tweaking the innards probably
is going to lead to excessive complication.

-James
We have two tables that — for legal reasons — are not allowed to be
combined. The data is so similar that we are using PostgreSQL table
inheritance ,
but we can’t return the information in the same page. Originally, we only
had one table with a column specifying which data set to use, but or
lawyers put an end to that.

So we have two tables tables with the exact same columns: product_foo and
product_bar. We also have two models that use model inheritance so that
they have the exact same fields: ProductFoo and ProductBar. The decision to
choose which table to use is handled based on user settings.

We would like to go back to just having the one Product model, and have its
table name switch as necessary. Is there a way to do that?

Peter of the Norse
rahmc...@radio1190.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+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/0A706025-5A66-47E3-B524-222E1780ADA4%40radio1190.org

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

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